jQuery Datatable Editor没有初始化

时间:2016-03-29 09:23:39

标签: javascript jquery datatables jquery-datatables-editor

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

TypeError: $.fn.dataTable.Editor is not a constructor

我所做的就是在创建表的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() ));

这些是页面中的.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

我错过了什么吗?提前谢谢。

更新

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

更新

我从页面中删除了bootstrap.min.js。控制台错误 “TypeError:a.Editor未定义”已删除。

2 个答案:

答案 0 :(得分:4)

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

答案 1 :(得分:-1)

我猜你错过了初始化。您需要初始化变量var editor = new $.fn.dataTable.Editor( {} ); 并为其赋值如:

import socket
import random

#Characters and places from HHGTTG to make it a little more difficult

word_list = [ 'agrajag','altairians','android','apple','arthur','beeblebrox',
              'betelgeuse','colin','dent','dentrassis','dolphins','eddie','fenchurch',
              'ford','galaxy','gargravarr','garkbit','god','golgafrinchans','guide',
              'hactar','harmless','hello','hitchhikers','hooloovoo','hyperspace',
              'krikkiters','lallafa','laminate','lamuella','magrathea','marvin',
              'panic','paranoid','prefect','random','roosta','russell',
              'slartibartfast','sorcerer','thor','towel','trillian','vogon','willow',
              'zaphod','zarniwoop','zarquon','zem']

lowercase = ['q','w','e','r','t','y','u','i','o','p','l','k','j','h','g','f',
             'd','s','a','z','x','c','v','b','n','m']

secret_word = random.choice(word_list)

guesses=0
letters_guessed = []
word = []


#while testing i used this a lot and i have left it in in case you want to cheat as well
#print(secret_word)

for x in range(len(secret_word)):
    word.append('_ ')

arthur = ("\n %s"%''.join(word))

def Main():
    host = ''
    port = 4242

    s = socket.socket()
    s.bind((host,port))

    s.listen(1)
    c, addr = s.accept()
    print("Connection from: " + str(addr), secret_word)
    while True:
        data = c.recv(1024).decode('utf-8')
        if not data:
            break
        print("from connected user: " + data)
        data = data.upper()
        print("sending: " + arthur)
        c.send(arthur.encode('utf-8'))
    c.close()

if __name__ == '__main__':
    Main()