2011-03-28 81 views
0

我有一个jquery使用下面的代码数据表:麻烦过滤通过Ajax的填充数据与jQuery数据表

// Test list table 
$('#dashboard_testlist_table').dataTable({ 
    "bJQueryUI": true, 
    "bAutoWidth": false, 
    "bProcessing": true, 
    "aaSorting": [[0, 'asc'], [2, 'asc']], 
    "sPaginationType": "full_numbers", 
    "sAjaxSource": projectTestListTablePopulateUrl, 
    "oLanguage": { 
     "sSearch": "Search all columns:" 
    }, 
    "aoColumns": [{ 
     "sTitle": "Protocol/Test/Case" 
    }, { 
     "sTitle": "Last Run" 
    }, { 
     "sTitle": "Last Build/Phase" 
    }, { 
     "sTitle": "Detail", 
    "sClass": "center" 
    }, { 
     "sTitle": "Owner" 
    }] 
}); 

我的服务器正确地发回JSON和表格填充预期。

我遇到的问题是我无法对表格进行任何过滤。搜索框中的任何字符都会立即过滤为不显示任何结果。我使用了很多数据表,这个让我疯狂。

我注意到,当我“查看页面源代码”时,源代码中没有呈现html。这是我的原版HTML:

<!--Test List Table--> 
<table id="dashboard_testlist_table" class="display"> 
<!--Table Header--> 
<thead> 
    <tr> 
     <th>Protocol/Test/Case</th> 
     <th>Last Run</th> 
     <th>Last Build/Phase</th> 
     <th>Detail</th> 
     <th>Owner</th> 
    </tr> 
</thead> 

<tbody> 
<!--Table Body, ajax populated, see /media/custom_js/user_dashboard.js --> 
</tbody> 
</table> 

页面加载后,它仍然显示相同。发送的JSON数据是否应该填充到那里?

否则,有没有人有什么建议先查找过滤这些数据?我正在使用jQuery数据表1.6.2。

回答

0

其实,这个问题最终被一些HTML,我是路过的那是JSON(链接)放入表中的td元素之一中。它是畸形的,正在引起头痛。

0

做u使用搜索查询在服务器端页面

的exaple这样

if ($_GET['sSearch'] != "") 
{ 
    $sWhere = "WHERE engine LIKE '%".mysql_real_escape_string($_GET['sSearch'])."%' OR ". 
         "browser LIKE '%".mysql_real_escape_string($_GET['sSearch'])."%' OR ". 
         "platform LIKE '%".mysql_real_escape_string($_GET['sSearch'])."%' OR ". 
         "version LIKE '%".mysql_real_escape_string($_GET['sSearch'])."%' OR ". 
         "grade LIKE '%".mysql_real_escape_string($_GET['sSearch'])."%'"; 


}