代码之家  ›  专栏  ›  技术社区  ›  TheOrdinaryGeek

呈现数据的数据表和列定义

  •  0
  • TheOrdinaryGeek  · 技术社区  · 6 年前

    我使用的是数据表1.10.19,我希望根据表单元格的内容筛选数据。

    我正在使用 columnDefs 选项更改返回数据的内容。

    我正在使用 this php script 以检索数据。

    我的代码是;

    $('#example').DataTable({
    processing : true,
    serverSide : true,
    ajax: url": '/server_processing.php',
    columnDefs: [{
        targets: 5, // row 6 in the html table
        "render": function(data, type, row) {
            if (row[5] == 0) {
                data = 'rejected';
            }
            return data;
        },
    }]
    });
    

    这成功地显示了一个表,并且 rejected 在第6列中,当 0 从数据库返回。但是,数据表不允许我在 单词 拒绝 . 我得到 No matching records found 但是我可以过滤整数 .

    我以为数据表应该过滤表中显示的内容?

    感谢您的任何建议。

    2 回复  |  直到 6 年前
        1
  •  0
  •   Gyrocode.com    6 年前

    已启用服务器端处理模式( serverSide: true )这意味着您必须在服务器端执行搜索。这可以手动完成,也可以使用助手类/库。

    例如,对于php,使用ssp helper类( ssp.class.php )在数据表分发中可用。对于Laravel框架,有 Laravel DataTables .

    数据表插件仅在客户端处理模式下执行搜索。

        2
  •  0
  •   TheOrdinaryGeek    6 年前

    简单地说,我所要做的就是设置这个;

    serverSide: false