EXTJS4 - For TreeStore, how to pass parameters and action methods?
I am using Extjs4 TreeStore, i want to know how to pass parameters (like mode = 'list') and action methods (POST or GET).
Thanks in advance.
EXTJS 3.x i have used like this it's working fine:
loader: new Ext.tree.TreeLoader({
dataUrl: 'content/permissions/server.php',
baseParams: {
mode: 'getPermissions'
}
})
EXTJS 4.x i have used like this but it is not working:
Ext.create('Ext.data.TreeStore', {
autoLoad: true,
proxy: {
type: 'ajax',
url: 'server.php'
},
extraParams: {
mode: 'getTree'
},
actionMethods: 'POST',
root: {
text: 'Tree',
id: 'src',
expanded: true
开发者_Go百科 }
});
Thanks, Riyaz
You should carefully check your configuration parameters with the current Ext JS 4 API Documentation.
What I see at first glance:
actionMethods is an object and not a string value configuration. It's implemented in both the AJAX and the REST proxies. If your need a full featured editable tree, consider a REST proxy. Only if you go beyond CRUD, you need to provide additional
actionMethods
to the REST proxy.extraParams belongs to the Proxy and not to the tree configuration.
So your store configuration should look like:
Ext.create('Ext.data.TreeStore', {
autoLoad: true,
proxy: {
type: 'ajax',
url: 'server.php',
extraParams: {
mode: 'getTree'
},
},
root: {
text: 'Tree',
id: 'src',
expanded: true
}
});
Have you verified if at least an Ajax request has been sent to the server? You can easily check this with FireBug.
example of correct setting:
actionMethods: {
destroy:'DELETE',
create: 'POST',
update: 'POST',
read: 'GET'
},
This the correct one
Ext.create('Ext.data.TreeStore', {
autoLoad: true,
proxy: {
type: 'ajax',
url: 'server.php',
extraParams: {
mode: 'getTree'
},
actionMethods: 'POST'
},
root: {
text: 'Tree',
id: 'src',
expanded: true
}
});
精彩评论