}
},
{ "data": "recordsbegindate","orderable": false },
{ "data": "recordsenddate" ,"orderable": false},
{ "data": "uploadsoundsids","orderable": false },
{"render":function ( data, type, row, meta )
{
var operationId = row.operationid;
return "<button type="button"οnclick="deleteOperation("+ operationId +"," +meta.row+ ")">删除</button>";
}}
];
可以看到,将后端给前端返回的出参,使用属性名依次绑定到列上,orderatble是说明这一列是否支持排序。render可以定义一个function也可以定义成其他属性,是用来转换数据的,比如返回的时间是一个时间戳,但是我要现实的是一个fomat的时间,就可以在render中转换。还有最后一行,我想在最后一列添加一个删除按钮,那这个删除按钮就可在这里通过数据的唯一索引来动态生成。
看下官方对render中使用function定义的说明:
function render( data, type, row, meta )
Description:
If a function is given, it will be executed whenever DataTables needs to get the data for a cell in the column. Note that this function might be called multiple times, as DataTables will call it for the different data types that it needs – sorting, filtering and display.
Parameters:
| Name | Type | Optional | |
|---|---|---|---|
| 1 | data | Any | No |
The data for the cell (based on columns.data) | |||
| 2 | type | string | No |
The type call data requested. This is used for DataTables’ orthogonal data support. This value will be one of: filter: Get the value that DataTables should use for filtering on this cell. See also the cell().render() method which can be used to execute the given rendering method at any arbitrary time. | |||
| 3 | row | Any | No |
The full data source for the row (not based on columns.data)
相关文章
大家在看
| |||










