ExtJs4 - 存储 baseParams 配置属性? [英] ExtJs4 - Store baseParams config property?
问题描述
在 extjs3.x 中,我使用商店 baseParams
配置属性来指定用于加载商店的参数.
这个属性在 extjs 4 中不再存在.我应该怎么做而不是这个?
In extjs3.x I used the stores baseParams
config property to specify parameters used to load the store.
This property no longer exists in extjs 4. What should I do instead of this?
也在 extjs3 中,我能够通过使用代理 method
配置属性来指定商店代理是 GET
还是 POST
方法.我应该怎么做而不是这个?
Also in extjs3 I was able to specify wether the stores proxy was a GET
or a POST
method by using the proxy method
config property. What should I do instead of this?
我的 ExtJs 3 代码 ->
My ExtJs 3 code ->
var store = new Ext.data.JsonStore({
root: 'Data',
baseParams: {
StartDate: '',
EndDate: '''
},//baseParams
proxy: new Ext.data.HttpProxy({
url: 'Time/Timesheet',
method: 'POST'
})//proxy
});//new Ext.data.JsonStore
推荐答案
您需要使用extraParams"代理属性来代替 Ext 3 中的 baseParams 代理属性.ExtJS 4 中的等效 JsonStore 如下所示:
You need to use the 'extraParams' proxy property in place of the baseParams one from Ext 3. An equivalent JsonStore in ExtJS 4 looks like this:
Ext.define('YourModel', {
extend: 'Ext.data.Model',
fields: ['field1', 'field2']
});
var store = new Ext.data.Store({
model: 'YourModel',
proxy: {
type: 'ajax',
url : 'Time/Timesheet',
root: 'Data',
extraParams: {
StartDate: '',
EndDate: ''
}
}
});
据我所知,HTTP 传输方法是根据 RESTful 原则根据您要完成的任务自动设置的.例如,如果您加载商店,则使用 GET 请求;创建新记录使用 POST 等
As far as I know, the HTTP transport method is set automatically according to RESTful principles according to what you're trying to accomplish. For example, if you load the store a GET request is used; creating a new record uses a POST, etc.
如有必要,您可以通过覆盖代理的 actionMethods 属性来覆盖它:
You can override this if necessary though, by overriding the actionMethods property of the proxy:
var store = new Ext.data.Store({
model: 'YourModel',
proxy: {
type: 'ajax',
url : 'Time/Timesheet',
root: 'Data',
actionMethods: {
read: 'POST'
},
extraParams: {
StartDate: '',
EndDate: ''
}
}
});
这篇关于ExtJs4 - 存储 baseParams 配置属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!