如何使用复选框服务器端脚本实现jQuery DataTable列过滤器?请告诉我过滤是否从serveside.php或使用JavaScript中完成的。我想实现像 https:// jquery-datatables-column-filter.googlecode.com/svn-history/r77/trunk/checkbox.html ,但使用服务器端脚本。

有帮助吗?

解决方案

在HTML文件中的DataTables初始化的代码。必须牢记有一件事初始化未在本地服务器上完成。代码必须在远程服务器上运行。

$(document).ready(function() {
var $dt = $('#example1').dataTable({
"bProcessing": true,
        "bServerSide": true,
        "bAutoWidth": false,
        "pagingType": "full_numbers",
        "sAjaxSource": "server.php",
        "aaSorting": [[3, "desc"]],
        "fnServerData": function(sUrl, aoData, fnCallback) {
        $.ajax({
        "url": sUrl,
                "data": aoData,
                "success": fnCallback,
                "dataType": "json",
                "cache": false
        });
        }
});
        //$dt.fnDraw();

        $dt.columnFilter({sPlaceHolder: "head:before",
                aoColumns: [
                        null,
                        null,
                        null,
                        null,
                        null,
                        null,
                        null,
                        null,
                {
                type: "checkbox",
                        values:
                        [
                        {value: '3', label: 'New'},
                        {value: '0', label: 'Pending'},
                        {value: '1', label: 'Active'},
                        {value: '2', label: 'Inactive'},
                        ]
                },
                        null,
                        null,
                        null,
                        null,
                        null,
                        null,
                        null,
                ]
        });
.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top