JsTree-grid undefined value from JSON

356 Views Asked by At

JsTree-grid plugin won't work as expected for me. I am getting node data (including data for grid columns) by AJAX request responding by JSON file.

JS snippet:

    .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 response from:

/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"
   }
]

Somehow node.seo_title is always undefined. Can you explain why this is? It seems the problem is with the grid plugin integration in jstree.

Versions: I am using jstree 3.3.3.0 and jstreegrid 3.4.2.

1

There are 1 best solutions below

0
On

Finally, I`ve make it work. The problem was in JSON data file. It has to have a bit different data structure:

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