简体   繁体   English

jQuery数据表搜索不起作用

[英]Jquery datatable searching is not working

i am using jQuery Datatable 1.10. 我正在使用jQuery Datatable 1.10。

Everything works great it binds the data in grid but when i try to implement search it is not working. 一切正常,它将数据绑定在网格中,但是当我尝试实现搜索时,它不起作用。

My code for search is here :- 我的搜索代码在这里:-

 $('#search-date').change(function () {
        alert(this.value);
        table.column([3]).search($(this).val()).draw(); //Here table is instance of datatable.
    });

Alert is called but it does not show the value in grid. 警报被调用,但是它不显示网格中的值。

Please help. 请帮忙。 Thanks 谢谢

If there are no errors in the console and correct json is sent in the response, look at the draw param under "Returned Data"; 如果控制台中没有错误,并且响应中发送了正确的json,请查看“返回的数据”下的绘制参数。 that needs to match what DataTables sends in the request. 需要匹配DataTables在请求中发送的内容。

On the server-side parse the request's "draw" param and send it back in the response along with search results. 在服务器端,解析请求的“绘制”参数,并将其与搜索结果一起发送回响应中。

If you have the DataTable in other language like 如果您有其他语言的数据表,例如

var table = $('#inventario').DataTable({
    "language": {
        "url": "//cdn.datatables.net/plug-ins/1.10.7/i18n/Spanish.json"
    }
});

You need remove the language feature like this 您需要删除这样的语言功能

 var table = $('#inventario').DataTable();

After, you need change the "oLanguage" property http://legacy.datatables.net/usage/i18n 之后,您需要更改“ oLanguage”属性http://legacy.datatables.net/usage/i18n

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM