1
如何让每个列的搜索/过滤器工作?datatables +每列添加一个过滤器
我正在建造一些小步骤,并且不断地添加到我的数据表中,这个数据表在这个阶段非常动态。它基本上建立一个基于数据的数据表。我现在添加了页脚作为搜索/过滤器,但不幸的是,这是我陷入困境的地方。我无法让文件管理器工作。建议非常感谢。
这里是我的http://live.datatables.net/qociwesi/2/edit
工作我的样本数据表,它基本上有一个建立由表dTableControl对象。
要建立我的表,我需要调用loadDataFromSocket其执行以下操作:
//then I have this function for loading my data and creating my tables
//file is an array of objects
//formatFunc is a function that formats the data in the data table, and is stored in options for passing to the dTableControl for formatting the datatable - not using this in this example
//ch gets the keys from file[0] which will be the channel headers
//then I add the headers
//then I add the footers
//then I create the table
//then i build the rows using the correct values from file
//then I draw and this then draws all the row that were built
//now the tricky part of applying the search to each columns
所以我有远了这一点,但每列搜索无法正常工作。我如何获得搜索/过滤器每列可用?
注意这是一个非常基本的工作的例子,我已经工作过:http://jsfiddle.net/HattrickNZ/t12w3a65/
tks,你能详细说明为什么我应该重写。 jsfiddle的例子是一个静态表,数据表工作,而我的例子是动态的,并能够绘制给它的东西。这是probs为什么它更复杂。你的回应将不胜感激,因为我只是一个新手! – HattrickNZ
@HattrickNZ,虽然你的代码允许你动态构建表,但我认为你的代码是不必要的复杂。这将导致未来维护中的错误和问题。代码复杂性很可能是你错误地使用't1'而不是't1.oTable'的原因。 –
tks但更具体地说是'dTableControl'对象构建数据表的复杂部分或'loadDataFromSocket'函数?或者它是一个组合? tks的建议,我会看到我可以如何简化它。 – HattrickNZ