Forum
/
Ext JS Community Forums 4.x
/
Ext: Q&A
/
-
13 Mar 2012 1:10 PM #1
Unanswered: autoLoad: false TreeStore in with TreePanel rootVisible: false
Hello, I understand the idea of autoLoad: false TreeStore the "no work" or work differently due to the expansion of the root. But if you do not want to display this root, there's no way I set it so that it is not expanded, since it is hidden. The main problem is I need to load the tree after it is rendered, but it strikes me the following error:
Code:records[i] is undefined ... ns[i].viewRecordId = records[i].internalId;
Code:<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <link rel="stylesheet" href="../resources/css/ext-all.css" type="text/css"> <script type="text/javascript" src="../ext-all-dev.js"></script> <script type="text/javascript"> Ext.define('Menu', { extend: 'Ext.data.Model', fields: [ {name: 'id', type: 'int'}, 'text', 'leaf' ], proxy : { type : 'ajax', url : 'menu.json', reader: {type: 'json'}, } }); Ext.onReady(function() { var store = Ext.create('Ext.data.TreeStore', { model : 'Menu', autoLoad: true }); Ext.create('Ext.tree.Panel', { renderTo : Ext.getBody(), height : 100, store : store, rootVisible: false }); store.load(); }); </script> </head> <body> </body> </html>
Code:[{ id : 1, text: 'Menu 1', leaf: true },{ id : 2, text: 'Menu 2', leaf: true }]
Thank you! -
14 Mar 2012 9:46 AM #2
-
Join Date
- Mar 2007 Location
- St. Louis, MO Posts
- 27,805 Vote Rating
- 325 Answers
- 2533
If you wanted to stop the loading you can return false in a beforeload event listener. Then to load you can do
Code:store.load({ node : rootnode });
Mitchell Simoens
Sencha Inc, Senior Forum Manager
@SenchaMitch
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in heavy development! Several chapters already available! -
14 Mar 2012 10:06 AM #3
As specifically stop load? return false just before the load is not going to stop .. I do not understand your code .. I put in the rootnode, if I do not want the menu has a root?
-
14 Mar 2012 10:11 AM #4
-
Join Date
- Mar 2007 Location
- St. Louis, MO Posts
- 27,805 Vote Rating
- 325 Answers
- 2533
Code:store.on('beforeload', function() { return false; });
Code:store.load({ node : store.getRootNode() });
Mitchell Simoens
Sencha Inc, Senior Forum Manager
@SenchaMitch
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in heavy development! Several chapters already available! -
14 Mar 2012 10:53 AM #5
Code:Ext.define('Compstoque.view.Menu' ,{ extend : 'Ext.tree.Panel', alias : 'widget.mainmenu', region : 'west', title : 'Menu', width : 200, minWidth : 150, maxWidth : 400, split : true, collapsible: true, store : 'Menu', rootVisible: false });
Code:Ext.define('Compstoque.store.Menu', { extend: 'Ext.data.TreeStore', model : 'Compstoque.model.Modulo' });
Code:... 'mainmenu' : { render : me.loadMenu, ... }, ... loadMenu: function(tree) { var store = tree.getStore(); store.on('beforeload', function() {return false;}); store.load({ node : store.getRootNode() }); },
store.jpg