2017-03-13 62 views
0

我在ASP.NET MVC Web應用程序中使用DataTables.net(1.10.12)進行服務器端處理(表格加載,沒有數據或控制器的問題)。當我添加可視域按鈕時,我得到可用域的列表,並且可以選擇和取消選擇我想要的列。DataTables.net colvis:可用字段的列表不會因失去焦點而消失

當我完成選擇或取消選擇字段時,問題就出現了 - 該列表在失去焦點時不會消失。

我錯過了什麼?

這裏是我的觀點:

<table class="table" id="tblMyIndex"> 
    <thead> 
     <tr> 
      <th>Field_A</th> 
      <th>Field_B</th> 
      <th>Field_C</th> 
     </tr> 
    </thead> 
</table> 

<script> 
    $(document).ready(function() { 
     var table = $('#tblMyIndex').dataTable({ 
      processing: true, 
      serverSide: true, 
      deferRender: true, 
      stateSave: true, 
      dom: 'lfBtipr', 
      buttons: ['colvis'], 
      ajax: { 
       "url": "/MyController/MyAction", 
       "type": "POST" 
      }, 
      columns: [ 
       { "data": "Field_A" }, 
       { "data": "Field_B" }, 
       { "data": "Field_C" } 
      ], 
      order: [[0, "asc"]] 
     }); 
    }); 
</script> 
,當我看着在Chrome中捕獲的錯誤

,它說以下(不知道這是有意義的任何人):

Uncaught TypeError: d(...).parents(...).andSelf is not a function 
at HTMLBodyElement.<anonymous> (dataTables.buttons.min.js:24) 
at HTMLBodyElement.dispatch (jquery-3.1.1.js:5201) 
at HTMLBodyElement.elemData.handle (jquery-3.1.1.js:5009) 

回答