繁体   English   中英

如何将ID添加到jQuery数据表中的列过滤器的类型选择元素

[英]how to add id to the type select element of column filter in jquery datatable

    oTable.columnFilter({
       sPlaceHolder: "head:before",
       aoColumns: [                    
           { type: "select", values: myArray},                                    
           { type: "text" },
           { type: "select", values: category }                                            
       ]
    });

我想将数据绑定到列过滤器的一个下拉列表,为此我需要为下拉列表分配ID或名称...如何实现此目的? 在这里,我使用的是数据表1.9版。

使用datatable的createdRow属性, 只要在datatable中创建任何行,都会自动创建rowId。 https://datatables.net/reference/option/createdRow for datatable 1.10+

有关数据表1.9的http://legacy.datatables.net/release-datatables/examples/advanced_init/row_callback.html

  "createdRow": function (row, data, rowId) {
    var $rowCreated = $(row);
    $rowCreated.data('rowData', data).attr('data-row-id', rowId);

    //Row Single-Click Event Handler
    $rowCreated.on('click', function () {
      var $rowClicked = $(this);
      var rowData = $rowClicked.data('rowData');
      $rowClicked.addClass('selected').siblings().removeClass('selected');
      // Do any operation for onClick
    });
  },

对于数据表1.9

$('#example').dataTable( {
        "fnRowCallback": function( nRow, aData, iDisplayIndex ) {
            //Here you have iDisplayIndex, the row index
        }
})

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM