【问题标题】:JsTree-grid undefined value from JSON来自 JSON 的 JsTree-grid 未定义值
【发布时间】:2017-01-09 16:03:38
【问题描述】:

JsTree-grid 插件无法按预期工作。我通过 JSON 文件响应的 AJAX 请求获取节点数据(包括网格列的数据)。

JS sn-p:

    .jstree({
    'core' : {
        'data' : {
            'url' : '/cms/ajax/ajax_json_tree.php?table=subpages_tree&operation=get_node',
            'data' : function (node) {
                return {
                    'id' : node.id,
                    'seo_title' : node.seo_title
                };
            },
            'dataType' : 'json'
        },
        'check_callback' : true,
        'themes' : {
            'responsive' : false
        }
    },
    'plugins' : ['state','dnd','contextmenu','grid'],
    grid: {
        columns: [
            {width: 300, header: "Name"},
            {width: 100, header: "SEO", value: "seo_title"}
        ]
    },
    'force_text' : true

})

JSON 响应来自:

/cms/ajax/ajax_json_tree.php?table=subpages_tree&operation=get_node

[
   {
      "id":255,
      "text":"NEWS",
      "children":true,
      "seo_title":"news"
   },
   {
      "id":256,
      "text":"DEVWEBMAIL",
      "children":false,
      "seo_title":"devwebmail"
   }
]

不知何故node.seo_title总是未定义。你能解释这是为什么吗?似乎问题在于 jstree 中的网格插件集成。

版本:我使用的是 jstree 3.3.3.0 和 jstreegrid 3.4.2。

【问题讨论】:

    标签: javascript jstree


    【解决方案1】:

    最后,我已经成功了。问题出在 JSON 数据文件中。它必须有一点不同的数据结构:

    [
       {
          "id":255,
          "text":"NEWS",
          "children":true,
          "data" {
              "seo_title":"news"
          }
       },
       {
          "id":256,
          "text":"DEVWEBMAIL",
          "children":false,
          "data" {
              "seo_title":"devwebmail"
          }
       }
    ]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-03-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多