javascriptjsonfancytree

Fancytree JSON parameter for activating a node


I am trying to initialize the Fancytree by AJAX call which returns a JSON. Is there any option in JSON to activate the initialized child node?

Below is my initialization JSON sample.

JS FT init:

/* ------*/
source: {
    url: "getTreeInitData",
    cache: false
},
/* ------*/

JS options:

activeVisible: true,
aria: true,
autoActivate: true,
autoCollapse: true,
autoScroll: false,
clickFolderMode: 4,
checkbox: false,
checkboxAutoHide: undefined,
debugLevel: 4,
disabled: false,
focusOnSelect: false,
escapeTitles: false,
generateIds: false,
idPrefix: "ft_",
icon: true,
keyPathSeparator: "/",
minExpandLevel: 1,
quicksearch: false,
rtl: false,
selectMode: 2,
tabindex: "0",
titlesTabbable: false,
tooltip: false

JSON data from URL "getTreeInitData":

[
  {
    "title": "Whole Country",
    "key": "cntry_level",
    "children": [
      {
        "title": "BENGALURU",
        "key": "13",
        "lazy": true,
        "selected": true
      }
    ]
  }
]

Once the init data is received, i want the child Bengaluru to be activated in the tree. As you can see from the above, i have tried with selected, but its mostly for checkboxes which i do not use in my tree.


Solution

  • Found the JSON option after going through the source code in docs of Fancy tree. I should have used "active" instead of "selected".

    [
      {
        "title": "Whole Country",
        "key": "cntry_level",
        "children": [
          {
            "title": "BENGALURU",
            "key": "13",
            "lazy": true,
            "active": true
          }
        ]
      }
    ]
    

    someone might as well know. Thanks!.