jQuery DataTable没有搜索框

jQuery DataTable没有搜索框,jquery,datatables,Jquery,Datatables,这可能是一个简单的问题,但我不知道该怎么做才能让搜索框位于网格顶部 这就是我得到的: var table = $('#tblCountries').DataTable({ "filter": false, "pagingType": "simple_numbers", "orderClasses": false, "order": [[0, "asc"]], "info": false, "scrollY": "450px", "scrollCollap

这可能是一个简单的问题,但我不知道该怎么做才能让搜索框位于网格顶部

这就是我得到的:

var table = $('#tblCountries').DataTable({
   "filter": false,
   "pagingType": "simple_numbers",
   "orderClasses": false,
   "order": [[0, "asc"]],
   "info": false,
   "scrollY": "450px",
   "scrollCollapse": true,
   "bProcessing": true,
   "bServerSide": true,
   "sAjaxSource": "DataWebService.asmx/GetTableData",
   "fnServerData": function(sSource, aoData, fnCallback) {
       aoData.push({ "name": "roleId", "value": "admin" });
       $.ajax({
           "dataType": 'json',
           "contentType": "application/json; charset=utf-8",
           "type": "GET",
           "url": sSource,
           "data": aoData,
           "success": function(msg) {
               var json = jQuery.parseJSON(msg.d);
               fnCallback(json);
               $("#tblCountries").show();
           },
           error: function(xhr, textStatus, error) {
               if (typeof console == "object") {
                   console.log(xhr.status + "," + xhr.responseText + "," + textStatus + "," + error);
               }
           }
       });
   },
   fnDrawCallback: function() {
       $('.image-details').bind("click", showDetails);
   }
});
datatable可以很好地处理数据和分页,但没有搜索框。

“filter”:true,
这将处理Datatables中的搜索框


如果
filter
不起作用,请尝试
bFilter
。在Datatables的当前版本中,它是
bFilter
,其默认值为true

如果这是服务器端处理和数据表的新版本,则使用:

searching: true,

请创建一个jsfiddle
“filter”:false,
是否是缺少搜索框的原因?您是如何处理服务器端代码中的分页的?请使用“filter”:true,而不是….或者根本不设置
filter
bFilter
filter
相等/表示从1.10.x开始相同,在此之前只有
bFilter
有效。但这只有在您想删除搜索框时才有意义。@davidkonrad我同意您的意见,如果您不设置,它将默认显示。谢谢Santosh。这回答了我的问题。但在我将其标记为答案之前,我注意到当我使用它时,它不会过滤网格。网格保持不变。有什么建议吗?@KaceyEzerioha您正在使用服务器端处理,因此您已从后端筛选数据这就是
HttpContext.Current.Request.Params[“sSearch”]我正在使用它来获取搜索文本。@giuseppe这几乎是3年前的事了。看起来它被弃用了。但我相信你可以在官方文件中找到类似的东西