按隐藏列对数据表进行排序

VB_

我有datatableid, firstName, lastName, phone, updated领域。

问题:datatable添加了四个字段(id,firstName,lastName和phone)。Updated字段被隐藏。

问题:如何datatableupdated字段排序

我的代码:

   $('#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]);
sree

从文档中:

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] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章