javascript EXTJS4 - 对于 TreeStore,如何传递参数和操作方法?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6425292/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
EXTJS4 - For TreeStore, how to pass parameters and action methods?
提问by Riyaz Ahamed
I am using Extjs4 TreeStore, i want to know how to pass parameters (like mode = 'list') and action methods (POST or GET).
我正在使用 Extjs4 TreeStore,我想知道如何传递参数(如 mode = 'list')和操作方法(POST 或 GET)。
Thanks in advance.
提前致谢。
EXTJS 3.x i have used like this it's working fine:
EXTJS 3.xi 像这样使用它工作正常:
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:
EXTJS 4.xi 已经这样使用了,但它不起作用:
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
}
});
Thanks, Riyaz
谢谢,里亚兹
采纳答案by Riyaz Ahamed
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
}
});
回答by Netzpirat
You should carefully check your configuration parameters with the current Ext JS 4 API Documentation.
您应该使用当前的Ext JS 4 API 文档仔细检查您的配置参数。
What I see at first glance:
我第一眼看到的:
actionMethodsis 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 RESTproxy. Only if you go beyond CRUD, you need to provide additional
actionMethods
to the REST proxy.extraParamsbelongs to the Proxy and not to the tree configuration.
actionMethods是一个对象,而不是一个字符串值配置。它在 AJAX 和 REST 代理中实现。如果您需要功能齐全的可编辑树,请考虑使用REST代理。只有当您超越 CRUD 时,您才需要提供额外
actionMethods
的 REST 代理。extraParams属于代理而不是树配置。
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.
您是否已验证是否至少有一个 Ajax 请求已发送到服务器?您可以使用FireBug轻松检查这一点。
回答by ivy
example of correct setting:
正确设置示例:
actionMethods: {
destroy:'DELETE',
create: 'POST',
update: 'POST',
read: 'GET'
},