dataTables获取当前行json格式数据

装载表格数据

 1 $(document).ready( function () {
 2      //页面加载后装载表格数据
 3     var table =  $('#mytable').DataTable( {
 4         "sProcessing": "处理中...",
 5              "ajax": {
 6                  "url": "/contact/getTableDatas",
 7              },
 8              "columns": [
 9                  { "data": "index",
10                   "render": function(data,type,row,meta){
11                     var startIndex = meta.settings._iDisplayStart;  
12                     return startIndex + meta.row + 1;  
13                   }
14                   },
15                  { "data": "name"},
16                  { "data": "state",
17                   "render":function(data,type,row){
18                         return "<button class='btn btn-danger' id='delete' name='delete' style='margin-left:10px;'>删除</button>";
19 
20                   }
21                   }
22              ],
23          } );

删除按钮绑定事件,获取该行数据

1  $(document).on("click","#delete",function(e){
2       var rowdata = table.row($(this).closest('tr')).data();
3      
4     });

 

posted @ 2016-12-23 18:00  suruozhong  阅读(4668)  评论(0编辑  收藏  举报