jQuery Datatable Editor没有初始化

lul*_*eco 6 javascript jquery datatables jquery-datatables-editor

我目前在页面中使用数据表.但是,当我尝试添加datatable编辑器插件时,我在控制台中收到错误:

TypeError: $.fn.dataTable.Editor is not a constructor
Run Code Online (Sandbox Code Playgroud)

我所做的只是在创建表的jquery中添加以下行:

 var table = $('#sampledt').DataTable();
 var editor = new $.fn.dataTable.Editor(table);
 new $.fn.dataTable.Buttons( table, [
  { 
    extend: "edit", editor: editor 
  },
  { 
    extend: "remove", editor: editor 
  }
]);

table.buttons().container()
     .appendTo( $('col-sm-6:eq(0)', table.table().container() ));
Run Code Online (Sandbox Code Playgroud)

这些是页面中的.js和.css:

jquery-1.12.0.min.js
bootstrap.min.js
jquery.dataTables.min.js
dataTables.bootstrap.min.js
dataTables.buttons.min.js
buttons.bootstrap.min.js
dataTables.select.min.js
dataTables.editor.min.js

bootstrap.min.css
dataTables.bootstrap.min.css
buttons.bootstrap.min.css
select.bootstrap.min.css
editor.bootstrap.min.css
Run Code Online (Sandbox Code Playgroud)

我错过了什么吗?提前致谢.

更新:

我添加了var editor = new $ .fn.dataTable.Editor(table); 删除了未定义"编辑器"的控制台错误.相反,发生了一个新错误:$ .fn.dataTable.Editor不是构造函数.

更新:

我从页面中删除了bootstrap.min.js.控制台错误"TypeError:a.Editor is undefined"已被删除.

njo*_*hsn 5

您是否正在使用免费试用版中的文件?确保您在试用期内购买了编辑器或获取了更新的文件


yes*_*nth -1

我猜你错过了初始化。您需要初始化变量editor并为其分配值,如下所示:

var editor = new $.fn.dataTable.Editor( {} );
Run Code Online (Sandbox Code Playgroud)