tree - ExtJs 4.2: TreePanel recursive root node load instead of children -
playing around extjs v4.2.1 (trial) not build complete treepanel json file. every time expanded/collapse children, request made server responded same json duplicating root node. first needed rood node interpreted json file , not hardcoded in store, second ajax request reading json file simulate server response.
so after lot of googling reading q/a here what i've tried:
- checked nodes leaf=true/false (see)
- hardcoded root node in store
- added loaded=true nodes (see)
- added reader proxy point root node in json response (see)
- played around rootvisible=bool
, many more ...
how load tree json including childrens in version of extjs (v4.2.1) ?
i didn't wanted bind event , workaround, had work without custom function or overwrite (there lot of workaround out there suggesting that).
so worked me:
view/menus.js:
ext.define('extapp.view.menus', { extend : 'ext.tree.panel', alias : 'widget.menus', store : 'menus', rootvisible : false, autoscroll : true, xtype : 'menus', viewconfig : { plugins : { ptype: 'treeviewdragdrop' } }, usearrows : true, });
store/menus.js:
ext.define('extapp.store.menus', { extend : 'ext.data.treestore', proxy : { type : 'ajax', url : 'path/to/file.json' }, root : { expanded: true } });
file.json (the . not loaded/visivle in tree):
{ text : '.', children: [{ text :'m0', id :'m0', leaf :true },{ text :'m1', expanded: true, id :'m1', children:[{ text :'m11', id :'m11', leaf :false, children:[{ text :'m111', id :'m111', leaf :true }] },{ text :'m12', id :'m12', leaf :false, children:[{ text :'m121', id :'m121', leaf :true }] },{ text :'m13', id :'m13', leaf :true },{ text :'m14', id :'m14', leaf :true }] },{ text :'m2', children:[{ text :'m21', id :'m21', leaf :true }] }] }
hope others saw lot of questions similar issues tree panel.
Comments
Post a Comment