2016-12-02 26 views
1

嗨我试图实现服务器端搜索使用datatable选择输入,但它似乎并没有将选定的输入值传递到服务器端。datatable Ajax数据输入选择搜索服务器端不工作

基本上它填充输入列表页脚和改变事件触发这一点,但所选择的值不会传递到服务器端...

我这么想吗?一些帮助将非常感激。

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>') 
        }); 
       }); 
      } 
     });   
    } 

回答

1

个别柱搜索值与参数columns[i][search][value]其从保持全局搜索值search[value]参数不同发送。

有关更多详细信息,请参阅Server-side processing

+0

谢谢。效果很好 – superted

相关问题