简体   繁体   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 }                                            
       ]
    });

I want to bind data to one dropdown of a column filter, for that I need to assign ID or name to the dropdown ...How can I achieve this? 我想将数据绑定到列过滤器的一个下拉列表,为此我需要为下拉列表分配ID或名称...如何实现此目的? Here I'm using datatable version 1.9.. 在这里,我使用的是数据表1.9版。

Use the property createdRow of datatable, The rowId is automatically created whenever there is any row created in the datatable. 使用datatable的createdRow属性, 只要在datatable中创建任何行,都会自动创建rowId。 https://datatables.net/reference/option/createdRow for datatable 1.10+ https://datatables.net/reference/option/createdRow for datatable 1.10+

http://legacy.datatables.net/release-datatables/examples/advanced_init/row_callback.html for datatable 1.9 有关数据表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
    });
  },

For datatable 1.9 对于数据表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