//初始化 加载数据 /* Init DataTables */ var oTable = $(‘#editable‘).dataTable({ bLengthChange: false, pageLength: 10, bPaginate: true, searching: false, ordering: false, processing: true, bServerSide: true, ajax: "/System/MGFuncInfo", columns: [ { "data": "FNumber" }, { "data": "FName" }, { "data": "FDescription" }, { "data": "FUrl" }, { "data": "FuncID" } ], columnDefs: [{ "targets": [4], "data": "FuncID", "render": function (data, type, full) { return "<button onclick=editinfo(‘" + full.FuncID + "‘); class=‘btn btn-primary ‘>編輯</button> <button onclick=deleteinfo(‘" + full.FuncID + "‘); class=‘btn btn-primary ‘>刪除</button>"; } }] });
// 新增数据 oTable.fnAddData(data); //删除数据 oTable.fnDeleteRow(RowIndex); //获取总行数 oTable.fnSettings().fnRecordsTotal(); //获取某行数据JSON oTable.dataTable().fnGetData(RowIndex); //获取DataTable 所有数据的JSON数组 oTable.api(true).rows().nodes().toArray();
原文:http://www.cnblogs.com/CoreXin/p/4729399.html