jquery datatables - 从 json 获取列

标签 jquery json datatables

在 jquery Datatables 中是否可以使用服务器端脚本定义列? 我需要这样的东西 enter image description here

必须从服务器加载带有日期的列。 然后列数可以变化。

最佳答案

我想我已经找到了你要找的东西

我将粘贴一些代码并发布一个类似 Q' 的链接,您将在其中获得更多信息...

$.ajax( {
    "url": 'whatever.php',
    "success": function ( json ) {
        json.bDestroy = true;
        $('#example').dataTable( json );
     },
    "dataType": "json"
} );

其中 json 是这样的

{

"aaData": [
[ "2010-07-27 10:43:08", "..."], [ "2010-06-28 17:54:33", "..."],
[ "2010-06-28 16:09:06", "..."], [ "2010-06-09 19:15:00", "..."]
] ,

 "aaSorting": [
  [ 1, "desc" ]
 ],

 "aoColumns": [
   { "sTitle": "Title1" },
   { "sTitle": "Title2" }
 ]

}

这里是原始线程的链接

Column definition via JSON array (ajax)

关于jquery datatables - 从 json 获取列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8665309/

相关文章:

javascript - ext js 网格面板滚动条不适用于 jquery

javascript - 显示和映射多个键及其对象数据

javascript - jQuery - 解析脚本标签内的 JSON

php - json编码€符号

jquery - 使用ajax刷新表格内容后重绘数据表?

html - 如何使fieldset动态扩展和压缩

php - 从数据库中获取字符串 Null

jQuery UI 可调整大小的 handle 点击区域/灵敏度/容差

ajax - 使用 AJAX 连接 Facebook HTML5 点赞和评论元素

javascript - jquery datatable 为对象初始化表添加复选框