DataTable AJAX数据输入选择搜索服务器端不起作用



hi im试图使用带有DataTable的选择输入来实现服务器端搜索,但似乎并未将所选输入值传递给服务器端。

基本上,它填充了页脚中的输入列表,并在更改事件上启动此列表,但不会将所选值传递给服务器端...

我想念什么吗?一些帮助将不胜感激。

var table = $('#tbl_product_list');
        // begin first table
        table.dataTable({
            // Internationalisation. For more info refer to http://datatables.net/manual/i18n
             "processing": true,
             "serverSide": true,
             "ajax":
             {
                 "url": "/Product/GetProductData",
                 "type": "POST",
                 "dataType": "JSON"
             },


             "columns": [                 
                 {
                     "data": "ProductName"
                 },
                 {
                     "data": "ProductCategory"
                 },
                 {
                     "data": "ProductType"
                 },
                 {
                     "data": "ProductSize"
                 },
                 {
                     "data": "CurrentQuantity"
                 },
                 { "data": null, "defaultContent": "<button class='btn btn-s yellow-gold ajax-edit' data-toggle='modal' type='button'> 수정 </button>" }
             ],               

            "bStateSave": true, // save datatable state(pagination, sort, etc) in cookie.
            "lengthMenu": [
                [10, 20, 30, 40,50],
                [10, 20, 30, 40,50] // change per page values here
            ],
            // set the initial value
            "pageLength": 10,            
            "pagingType": "bootstrap_full_number",
            "order": [
                [0, "asc"]
            ],
            "createdRow": function (row, data, dataIndex) {
                $(row).find('td:eq(12) button').attr('data-url',  '/Product/GetProductEditForm/' + data["ProductID"]);                 
            },
            "initComplete": function () {
                this.api().columns([1, 2, 3]).every(function () {
                    var column = this;
                    var select = $('<select class="form-control input-sm"><option value=""></option></select>')
                        .appendTo($(column.footer()).empty())
                        .on('change', function () {
                            var val = $.fn.dataTable.util.escapeRegex(
                                $(this).val()
                            );
                            console.log(val);       
                            this.search(val).draw();
                        });
                    column.data().unique().sort().each(function (d, j) {
                        select.append('<option value="' + d + '">' + d + '</option>')
                    });
                });
            }
        });        
    }

单个列搜索值是用参数columns[i][search][value]发送的,该参数与保存全局搜索值search[value]的参数不同。

有关更多详细信息,请参见服务器端处理。

最新更新