数据表从服务器端过滤

时间:2013-08-21 14:35:50

标签: php jquery datatables server-side

我使用数据表和列过滤器附加组件来显示和过滤数据库中的数据。我实现了多选择过滤的复选框。我所能做的就是复选框过滤器的预定义值,但我需要从数据库中复选框过滤器值。

jQuery('#tabela').dataTable({
                   "oLanguage": {
                   "sSearch": "Search:",
                   "sInfoFiltered": '' 
                    },
                   "bProcessing": true,
                   "bServerSide": true,
                   "sServerMethod": "GET",
                   "sAjaxSource": "server.php",
                   "fnServerParams": function(aoData) {
                                     aoData.push({"name" : "more_data", 
                                                 "value" : "my_value"})
                          },
                   "bJQueryUI": true
                   }).columnFilter({
                              aoColumns: [
                                         { type: "checkbox", 
                                           values: ["Filter Cola 1", 
                                           "FIlter Cola 2", "FIlter Cola 3"]},
                                         {},
                                         { type: "checkbox",
                                           values: ["Filter Colc 1", 
                                           "FIlter Colc 2","FIlter Colc 3"]}
                              ]
                    });

如何从服务器端设置复选框过滤器值?

1 个答案:

答案 0 :(得分:0)

jQuery('#tabela').dataTable({
                   "oLanguage": {
                   "sSearch": "Search:",
                   "sInfoFiltered": '' 
                    },
                   "bProcessing": true,
                   "bServerSide": true,
                   "sServerMethod": "GET",
                   "sAjaxSource": "server.php",
                   "fnServerParams": function(aoData) {
                                     aoData.push({"name" : "more_data", 
                                                 "value" : "my_value"})
                          },
                   "bJQueryUI": true
                   }).columnFilter({
                              aoColumns: [  { type: 'checkbox',
                        data: "{'Pending':'Pending','Complete':'Complete'}"// use like this type  i am just giving an idea use with your data it will work i used this way and it works

                                }

                              ]
                    });