小编Com*_*ler的帖子

如何动态添加没有"请求的未知参数"错误的行

我是DataTables的新手,我在向数据表动态添加新行时遇到了问题.

这是我的初始化:

table = $("#college-list").DataTable({
    'ajax': {
       'url': 'admin/get_college',
       'type': 'GET'
    },
    'columns': [
       { 'data': 'college_abbrev', "bSortable": true  },
       { 'data': 'college_name' , "bSortable": true },
       {
         "mData": null,
         "bSortable": false,
         "mRender": function(data, type, college) {
            return '<button type="button" class="btn btn-primary edit-college table-condensed">Edit</button>'
                   +'<button data-id="' + college.college_id  + '" type="button" class="delete-college btn btn-primary table-condensed" href="">Delete</button>';
          }
       }
    ]
});
Run Code Online (Sandbox Code Playgroud)

这里是添加一个新行(当我使用的示例代码ca,cn以及college_id是变量):

table.row.add( [
    {
       "college_abbrev": ca,
       "college_name": cn,
       "button":'<button type="button" class="btn btn-primary edit-college table-condensed">Edit</button>' …
Run Code Online (Sandbox Code Playgroud)

javascript ajax jquery datatables

7
推荐指数
1
解决办法
2451
查看次数

标签 统计

ajax ×1

datatables ×1

javascript ×1

jquery ×1