2017-01-09 52 views
0

JsTree網格插件將無法正常工作。通過由JSON文件響應的AJAX請求獲取節點數據(包括網格列的數據)。從JSON JsTree網格未定義的值

JS片段:從

.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 &操作= get_node

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

不知何故節點.seo_title永遠是undefine d。你能解釋這是爲什麼嗎?看來問題在於jstree中的網格插件集成。

版本:我正在使用jstree 3.3.3.0和jstreegrid 3.4.2。

回答

0

最後,我讓它工作。問題出在JSON數據文件中。它必須有一個不同的數據結構:

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