【问题标题】:cloumnfilter not working jquery datatables in serverside preprocessing列过滤器在服务器端预处理中不起作用 jquery 数据表
【发布时间】:2014-09-17 06:29:23
【问题描述】:

Columanfilter 在服务器端预处理的数据表中不起作用。带有列搜索的数据表不起作用。下面的代码是示例代码。请在 jsdiddle 或其他任何地方提供。请帮我。 这是javascript代码

$(document).ready(function() {

 drawDataTable = function()
    {
    $('#example').dataTable( {
        "processing": true,
        "serverSide": true,
        "ajax": "../server_side/scripts/server_processing.php",
        "sPagination": "full_numbers",
         "bFilter": true,
        "oSearch":{
               "sSearch":"",
               "bRegex": false,
               "bSmart": true },
        "aoColumns":[
               {"bSearchable": true},
                null,
                null,
                null
               ]    
    })
        .columnFilter({         
        aoColumns: [{
            type: "text"
        }, {
            type: "text"
        }, {
            type: "text"
        },{
            type: "text"
        }]
        });
    }   

    drawDataTable();


} );

这是HTML代码

<table id="example" class="display" cellspacing="0" width="100%">
                <thead>
                    <tr>
                        <th>Name</th>
                        <th>Position</th>
                        <th>Office</th>
                        <th>Extn.</th>

                    </tr>
                </thead>

                <tfoot>
                    <tr>
                        <th>Name</th>
                        <th>Position</th>
                        <th>Office</th>
                        <th>Extn.</th>

                    </tr>
                </tfoot>
            </table>

【问题讨论】:

    标签: javascript php jquery ajax jquery-datatables


    【解决方案1】:

    看起来你在theadtfoot 之间缺少你的身体:

                <tbody>
                    <tr>
                        <td>Name</td>
                        <td>Position</td>
                        <td>Office</td>
                        <td>Extn.</td>
    
                    </tr>
                </tbody>
    

    【讨论】:

    • 放置此代码后,我们会进行搜索,它会显示正在处理...然后它就会被击中。@Zee Tee
    • 您的 JSON 数据似乎有问题,您查看过是否有任何错误?
    • 您应该使用 firebug 来测试您的 JSON 脚本的响应。否则你就是在黑暗中做这一切。
    • JSON 数据没有错误。能否提供示例。@Zee Tee
    • 当您进行过滤搜索时,它会点击您的 php 脚本或您使用的任何内容来返回特定于该搜索的数据。你都设置好了吗?
    【解决方案2】:

    似乎没有正确传递 sSource 值。 sSource 基本上是 DataTables.js 中的“ajax”url 值。我对此的解决方案是从 columnFilter.js 文件中第 796 行的 DataTable ajax 值重新添加 sSource:

    sSource = sSource ? sSource : oTable.fnSettings().ajax;
    

    所以它看起来像:

    oTable.fnSettings().fnServerData = function (sSource, aoData, fnCallback) {
      sSource = sSource ? sSource : oTable.fnSettings().ajax;
      ....
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-11-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-05-17
      • 2012-05-30
      相关资源
      最近更新 更多