-
30 Apr 2011 2:35 AM #1
Unanswered: [4.0.0] MVC data.TreeStore and controller: this.store is undefined
Unanswered: [4.0.0] MVC data.TreeStore and controller: this.store is undefined
Hi,
Despite the efforts of unit testing, it seems like MVC is not completely finished/tested yet in the final 4.0 code.
I run into several problems (groupField on grid, see help-forum, searchfield store problem, root-property needs to be defined in the controller instead of store for a TreePanel (see help-forum), referencing to a component from a controller needs the use of prototype eg: Ex.view.tree.Tree.prototype.expandAll) and now again I get this message (again, store related):
this.store is undefined
http://localhost/ext-4.0.0/ext-all-debug.js
Line 87251
return this.store.getRootNode()
I just have a toolbar in a TreePanel with a button. From the controller I want to call the expandAll function...
If someone of the Dev-team needs an example, I'm happy give my code.
I'm really excited about the new stuff and developing apps using MVC seems easier (my first attempt to MVC, when it is working), but I agree with some people that this version (4.0.0) should be a Beta4. It is just not stable enough and lacks good documentation (I might have overlooked it, but I can't find the properties for trees like 'leaf', 'iconCls' etc, the search bar on top is not clickable. Slow loading, host not reachable sometimes).
At least I'm glad I haven't bought a license yet and that I have not committed myself for any clients to use ExtJs-4.
The framework is very promissing, but a lot of bugs should be fixed really quick before people running away and use something else less buggy. I also bought ExtDesigner some time ago, but no support for 4.0 when ExtJS 4 is released also makes me sad (I know it's coming, but when? and probably with a lot of errors again and likely no MVC structure possibility)
I still like the effort the Dev team puts in and ExtJs in general. It's visually the best javascript framework and I am a fan from the beginning. So keep up the good work and I'm sure a lot of bugs will be fixed in the forthcoming 4.0.1. I just can't wait till it's released!
Maurice.
-
30 Apr 2011 11:15 AM #2
Had the same problem with releases before beta3. At this time regStore was not deprecated, but the problem is the same.
No one from Sencha gave a hint or marked this as a bug and I'm tired to push the thread.
Perhaps you have more luck than I have
-
1 May 2011 9:30 AM #3
Boiled down using examples/app/simple
Boiled down using examples/app/simple
The following demonstrates the getRootNode failure using the examples/app/simple application:
The workaround for this (for me) was to create the TreeStore inline with the TreePanel. However even then it doesn't seem to firing loads for 'ajax'/'rest' proxies.Code:diff --git a/app/store/Users.js b/app/store/Users.js index fbf8f55..c4de03d 100644 --- a/app/store/Users.js +++ b/app/store/Users.js @@ -1,5 +1,5 @@ Ext.define('AM.store.Users', { - extend: 'Ext.data.Store', + extend: 'Ext.data.TreeStore', model: 'AM.model.User', autoLoad: true, @@ -15,4 +15,4 @@ Ext.define('AM.store.Users', { successProperty: 'success' } } -}); \ No newline at end of file +}); diff --git a/app/view/user/List.js b/app/view/user/List.js index 731a1d9..7c684fc 100644 --- a/app/view/user/List.js +++ b/app/view/user/List.js @@ -1,5 +1,5 @@ Ext.define('AM.view.user.List' ,{ - extend: 'Ext.grid.Panel', + extend: 'Ext.tree.Panel', alias : 'widget.userlist', title : 'All Users',Last edited by wcravens; 1 May 2011 at 9:36 AM. Reason: I _thought_ I hit preview
-
1 May 2011 10:07 AM #4
I have also dealt with this issue
I have also dealt with this issue
I have been creating an app while looking to the MVC guide for instruction and I ran into this issue as well. My solution for now (not sure if its correct for long term) is in code below.
Define my store in app/store/Folders.js
Now define my tree in app/view/folder/Tree.jsCode:Ext.define('MY.store.Folders', { extend: 'Ext.data.TreeStore', folderSort: true, proxy: { extraParams: { c: 'folders_controller', m: 'get' }, type: 'ajax', url: 'server/index.php' }, sorters: [ { property: 'sort_order', direction: 'ASC' } ] });
Code:Ext.define('MY.view.folder.Tree', { extend: 'Ext.tree.Panel', ... initComponent: function () { this.store = Ext.create('MY.store.Folders', { listeners: { load: { fn: this.onFoldersLoad, scope: this } }, root: { text: 'My Root', expanded: true } }); this.callParent(arguments); }, ... });Last edited by mxracer; 1 May 2011 at 10:10 AM. Reason: Had typo
-
2 May 2011 4:11 AM #5
The trick is to have some root configuration in the TreePanel (even if blank).
See: http://www.sencha.com/forum/showthre...pported-in-MVC
Code:Ext.define('MyTree', { extend: 'Ext.tree.Panel', store: 'MyTreeStore' ... //KLUDGE : Workaround for this thread root: { } });
-
2 May 2011 8:19 PM #6
From the API Docs:
The above approaches (specifying a root config or instantiating the store in the view) seem to violate the intent of the MVC approach where stores are created in the controller.Code:root : Boolean Allows you to not specify a store on this TreePanel. This is useful for creating a simple tree with preloaded data without having to specify a TreeStore and Model. A store and model will be created and root will be passed to that store.
It makes sense to me to have some partial definition of the root node that is used for the initial request from the store. However when I try this approach (letting the controller instantiate the store) it appears to be creating a store without a getRootNode method.
-
2 May 2011 10:54 PM #7
For even more giggles...
I have defined a store that extends TreeStore, a panel that extends TreePanel and have wired it all up according to the MVC intro docs. This produces the error "me.store.getRootNode is not a function" as described above.
However, in the firebug console "Ext.StoreManager.lookup('MyStore').getRootNode()" returns a well formatted node object.
-
3 May 2011 12:07 AM #8
Finally got it working almost to my satisfaction.
Note for reference I am working with an inline store (specifying it's data with a root config) as opposed to a remoting store for which the empty root in the panel config may be more elegant.
My fix is a simple modification of the initComponent creation version above.
This does however allow you to use the store created in the controllerCode:Ext.define('MY.view.MyTree', { extend: 'Ext.tree.Panel', store: 'MyStore', initComponent: function () { this.store = Ext.StoreManager.lookup(this.store); this.callParent(arguments); } });
Now on to working out how to fix the width of this panel when you put it in an Accordion >.<
-
3 May 2011 2:33 AM #9
I also struggled with the TreePanel, MVC and Stores in the beginning. The solution is to include a reference to your store in the Controller and have a rootNode defined in the View (treePanel). Just follow the latest MVC guide which you can find in the API docs.
PHP Code:// Define the Store
Ext.define('My.store.Folders', {
extend: 'Ext.data.TreeStore',
proxy: {
type: 'ajax',
url: 'folders/tree.php'
}
});
// Define the View
Ext.define('My.view.folders.Tree', {
extend: 'Ext.tree.Panel',
alias: 'widget.foldertree',
// Define root here as a workaround
root: {
text: 'root node'
},
rootVisible: false,
store: 'Folders', // The store loaded by the Controller
initComponent: function () {
// Do something here
this.callParent(arguments);
}
});
// Define the controller
Ext.define('My.controller.Folders', {
extend: 'Ext.app.Controller',
// Stores to load
stores: ['Folders'],
// Views to load
views: [
'folders.Tree'
],
init: function () {
// Control
this.control({
'foldertree': {
'itemclick': this.openItem
}
});
},
openItem: function() {}
});
-
3 May 2011 3:13 AM #10
bas_tzx: Would you mind referencing the 'MVC Guide' more specifically? I couldn't/can't find a MVC TreePanel/TreeStore example in the guide/s anywhere.
Typically I reference local documentation and expect the online docs to also remain in static until a new release is available for download (but I can understand why this may not be the Sencha strategy). So I double checked the current online docs and I still can't seem to find a MVC example of a TreePanel/TreeStore.
Thanks.
Similar Threads
-
Referencing a store from the controller
By matteoli in forum Ext: DiscussionReplies: 5Last Post: 28 Apr 2011, 7:43 AM -
extjs - ‘Store is undefined’ - data grid
By Flukey in forum Ext 3.x: Help & DiscussionReplies: 1Last Post: 11 May 2010, 3:04 AM -
how to post data to controller
By sukhi.tambar in forum Ext 2.x: Help & DiscussionReplies: 2Last Post: 17 Apr 2009, 4:31 AM -
Can't access data store, just getting undefined
By arnigudj in forum Ext 1.x: Help & DiscussionReplies: 5Last Post: 12 Jul 2007, 7:26 AM


Reply With Quote