我有datatable
与id, firstName, lastName, phone, updated
领域。
问题:我datatable
只添加了四个字段(id,firstName,lastName和phone)。Updated
字段被隐藏。
问题:如何datatable
按updated
字段排序?
我的代码:
$('#table').dataTable({
sDom: '<"top"fi>tS',
sScrollY: ($(window).height() - 250) + "px",
bPaginate: false,
bDeferRender: true,
bAutoWidth: false,
oLanguage: {
sInfo: "Total: _TOTAL_ entities",
sEmptyTable: "No pending entities"
},
"aoColumnDefs": [
{ "iDataSort": 4, "aTargets": [ 0 ] }
],
"aoColumns": [
{ "sWidth": "10%" },
{ "sWidth": "40%" },
{ "sWidth": "30%" },
{ "sWidth": "20%" },
{ "sTitle": "updated ", "bVisible":false }
],
fnCreatedRow: function( nRow, aData, iDataIndex ) {
$(nRow).attr('id', aData[0]);
}
});
table.fnAddData([id, firstName, lastName, phone, updated]);
iDataSort选择该列进行排序时希望对之进行排序的列索引(从0开始!)。例如,这可用于对隐藏列进行排序。
Default: -1
使用自动计算的列索引
Type: int
// Using aoColumnDefs $(document).ready( function() { $('#example').dataTable( { "aoColumnDefs": [ { "iDataSort": 1, "aTargets": [ 0 ] } ] } ); } ); // Using aoColumns $(document).ready( function() { $('#example').dataTable( { "aoColumns": [ { "iDataSort": 1 }, null, null, null, null ] } ); } );
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句