ExtJs4 - Store BaseParams配置属性? [英] ExtJs4 - Store baseParams config property?
问题描述
在extjs3.x中,我使用了商店 baseParams
config属性来指定用于加载商店的参数。
此属性不再存在于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中,我能够指定商店代理是一个 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 - Store BaseParams配置属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!