如何在数据表中添加长度菜单旁边的选择下拉列表?

时间:2015-09-12 17:36:31

标签: javascript jquery datatable datatables

我想在长度菜单旁边添加一个自定义下拉过滤器,如下图所示

我用

尝试了
var product = '<select id="product"><option value="consoles">Consoles</option><option value="peripherals">Peripherals</option></select>';

var config = {
    "bProcessing": true,
    "bServerSide": true,
    "sAjaxSource": "http://localhost/app/get_products",
    "fnDrawCallback": function() {
      if($('.dataTables_length').find('#product').length < 1){
          $('.dataTables_length').append(product);
      }
    },
    "fnServerParams" : function ( aoData ) {
        var type = $("#product").val();
        aoData.push({ "name": "type", "value": type });
    },
    "fnServerParams" : function ( aoData ) {
        var type = $("#product").val();
        aoData.push({ "name": "type", "value": type });
    }
  };

$('#table').dataTable(config);

下拉列表已插入,但它有很多错误。它的选定值不是持久的,并且数据表选项更改或分页更改的更改。

实现这一目标的正确方法是什么?

0 个答案:

没有答案