2012-11-29 88 views
0

我刚刚添加DataTables列过滤器附加到我的数据表,它显示页脚上的列搜索字段。但是,如果我输入“处理”是短时间完成的,但结果不会更新。即过滤。DataTables列过滤器附加显示,但输出未过滤

我在后端使用codeIgniters ignitedDatatables。其他一切正常(分页,右上角的全局搜索) 我发现网络上没有线索,无论我是否需要配置其他内容以使过滤器正常工作。

这里是我的视图 -

<html> 
<head> 
    <link rel="stylesheet" type="text/css" href="http://localhost/eshop/css/admin/style.css" /> 

    <script type="text/javascript" language="javascript" src="<?php echo base_url() ?>js/jquery-1.8.2.min.js"></script> 
    <script type="text/javascript" language="javascript" src="<?php echo base_url() ?>js/jquery.dataTables.min.js"></script> 
    <script type="text/javascript" language="javascript" src="<?php echo base_url() ?>js/jquery.dataTables.columnFilter.js"></script> 


    <link rel="stylesheet" type="text/css" href="<?php echo base_url() ?>css/jquery.dataTables_themeroller.css"/> 

    <link rel="stylesheet" href="http://localhost/eshop/css/admin/smoothness/jquery-ui-custom.css"/> 

    <script> 

     $(document).ready(function() { 
      $('#data_table').dataTable({ 
       "bProcessing": true, 
       "bServerSide": true, 
       "bJQueryUI": true,   
       "sPaginationType": "full_numbers", 
       "sAjaxSource": "<?php echo base_url() ?>grid/getCustomers" 
      }).columnFilter(
      { 
       aoColumns: [ 
        { 
         type: "number" 
        }, 
        { 
         type: "text", 
         bRegex: true, 
         bSmart: true 
        }, 
        null 
       ] 
      } 
     ); 

     }); 

    </script> 

</head> 
<body> 
    <div class="widget_body"> 
     <table id="data_table" class="data_table"> 
      <thead> 
       <tr> 
        <th>ID</th> 
        <th>First Name</th> 
        <th>Last Name</th> 
       </tr> 
      </thead> 
      <tbody> 
       <tr> 
        <td></td> 
        <td></td> 
        <td></td> 
       </tr> 
      </tbody> 
      <tfoot style="background-color: whitesmoke;"> 
       <tr> 
        <th></th> 
        <th></th> 
        <th></th> 
       </tr> 
      </tfoot> 
     </table> 
    </div> 
</body> 

我的控制

//display 
public function index() 
{ 
    $this->load->view('datatableview'); 
} 

//ajax request handler 
public function getCustomers() 
{ 
    $this->load->library('datatables'); 

    $this->datatables->select('id,first_name,last_name') 
      ->from('data_table'); 
    echo $this->datatables->generate(); 


} 

正如我前面所说的2个输入框出现在标识和名字的底部,但我看不到变化显示一旦我键入框

如果我键入=“Bjo”在第二列的输入b张不开从萤火GET请求,我发现是

_=1354249241305 
bRegex=false 
bRegex_0=false 
bRegex_1=true 
bRegex_2=false 
bSearchable_0=true 
bSearchable_1=true 
bSearchable_2=true 
bSortable_0=true 
bSortable_1=true 
bSortable_2=true 
iColumns=3 
iDisplayLength=10 
iDisplayStart=0 
iSortCol_0=0 
iSortingCols=1 
mDataProp_0=0 
mDataProp_1=1 
mDataProp_2=2 
sColumns= 
sEcho=22 
sRangeSeparator=~ 
sSearch= 
sSearch_0= 
sSearch_1=Bjo 
sSearch_2= 
sSortDir_0=asc 

的响应被发现

{"sEcho":22,"iTotalRecords":30,"iTotalDisplayRecords":30,"aaData":[["1","Shabab","Haider"],["2","Anas","Numan"],["3","Bjoy","Manik"],["4","Bjoy","Manik"],["5","Bjoy","Manik"],["6","Bjoy","Manik"],["7","Bjoy","Manik"],["8","Bjoy","Manik"],["9","Bjoy","Manik"],["10","Bjoy","Manik"]],"sColumns":"id,first_name,last_name"} 

编辑:它已经有一段时间,因为我用的是添加上。我在github中用我的过滤代码创建了一个分支。但它需要一些测试。我想测试一下自己,当我得到的时间。同时,如果有人想成为一个亲爱的,做它取诚待人

https://github.com/shababhsiddique/Ignited-Datatables/blob/Branche_Column_Filter/application/libraries/Datatables.php 

这是我很久以前实际使用的代码。它的老检查,如果它适用于您的版本

https://drive.google.com/file/d/0BzKzAVzAWPRgcmNCbGhnU3pqaW8/view?usp=sharing 
+0

您是否检查过请求的开发工具/萤火虫?这可能会发回500或db错误。 – stormdrain

+0

我可以给你什么信息?请告诉我。我以前没有使用这种类型的工具。无论如何,我已经更新了萤火虫获取请求的问题 – shababhsiddique

+0

https://developers.google.com/chrome-developer-tools/docs/network – stormdrain

回答

0

我只是觉得有一个json生成库的问题。

ignited datatables library不完整。我不得不修改他们的库到

我不记得我所做的所有更改(那里有不少),但我记得我改变了所有输入 - >到输入 - >后和所有$ _GET到$ _POST

我想我还修改了此功能

protected function get_filtering() 

这是当前编辑的图书馆我使用 -

{ http://162.212.134.58/shabab/Datatables.zip }

您可以将您的图书馆与我的图书馆进行匹配以找出答案。

我还没有更新到最新的数据表。

+0

我有同样的问题。你能帮我解决吗?或者您可以使用您所做的解决方案更新您的答案,以便我和其他像我这样的人可以通过您的解决方案解决我们的问题。 –

+1

你好Sizzling Code,很抱歉回复迟到。一段时间后,我刚刚来到SO,你的评论是我在一个月内在SO写的第一件事。如果你还没有解决你的问题,只需保持联系,我会尝试编辑答案。 – shababhsiddique

+0

@shababhsiddique你可以请张贴修改后的数据表库。我面临着同样的问题 –