jquery datatables - 从 json 获取列
在 jquery Datatables 中是否可以使用服务器端脚本定义列? 我需要这样的东西
必须从服务器加载包含日期的列。 然后列数可以变化。
In jquery Datatables is it possible to define columns with a server-side script?
I need something like this
The columns with dates have to be loaded from server.
Then number of columns can vary.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我想我已经找到了您正在寻找的内容
,我将粘贴一些代码并发布一个指向类似 Q' 的链接,您将在其中获得更多信息...
其中 json 是这样的
,这里是原始线程的链接
通过 JSON 数组(ajax)定义列
I think I have found what you were looking for
I will paste some code + post a link to a similar Q' in which you will get much more info...
where json is something like this
here a link to the original thread
Column definition via JSON array (ajax)
扩展 Kamal Deep Singh 的说法:
您可以动态创建表,然后将数据表应用于它以获得数据表的功能。
然后:
请注意,您可以像平常一样将设置放入 .dataTable() 中,但是不能将设置放在“sAjaxSource”或任何关联的数据获取函数中——这是将数据表应用于已经存在的表,这是我们动态创建的表。
好吧,这是一种很奇怪的方法,但它应该有效。
目前还没有内置的方法可以动态地对数据表执行此操作。请参阅此处:https://github.com/DataTables/DataTables/issues/273
To expand on what Kamal Deep Singh was saying:
You could dynamically create the table on the fly, then apply datatables to it to get datatables' functionality.
and then:
Note you can put settings in that .dataTable() as normal, however, not 'sAjaxSource' or any of the associated data-getting functions -- this is applying datatables to an already existing table, one we created on the fly.
Ok, so it's kind of a hacky way of doing it, but it should work.
There isn't currently a built in method of doing this with datatables dynamically. See here: https://github.com/DataTables/DataTables/issues/273