【问题标题】:Issues with jQuery Datatables filters outside table wrapperjQuery Datatables 过滤器在表包装器之外的问题
【发布时间】:2014-06-17 15:40:42
【问题描述】:

我有这张桌子http://www.keenthemes.com/preview/index.php?theme=metronic_admin&page=index.html

它使用数据表通过 ajax 加载数据。我将过滤器移到表格包装器之外,但是当我这样做时,过滤器功能不再起作用。有没有人有关于如何绑定外部过滤器表单并将其附加到数据表的示例?

我在 http://jquery-datatables-column-filter.googlecode.com/svn/trunk/external.html 找到了一些东西,但它纯粹是记录在案的,我无法让它工作。

谢谢

【问题讨论】:

    标签: javascript jquery datatable datatables jquery-datatables


    【解决方案1】:

    我为此使用fnServerParams

    这是在数据表初始化代码中:

    var oTable = $('#table').dataTable({
            "fnServerParams": function (aoData) {
            aoData.push({ "name": "myParam", "value": $('#mySelector').val() });
          }
    

    您的外部表单调用表格的 fnFilter 方法:

    $('#mySelector').click(function(e){
        e.preventDefault();
        oTable.fnFilter(this.value)
    });
    

    我使用的是服务器端数据源,所以会使用Request.QueryString["myParam"]获取传递的参数,你的填表方法可能不同。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-08-04
      • 1970-01-01
      • 1970-01-01
      • 2018-10-08
      • 2013-06-03
      • 2018-05-01
      • 2015-08-27
      • 2019-08-16
      相关资源
      最近更新 更多