You have to override actionMethod property
Ext.define('Sencha.store.Teams', {
extend: 'Ext.data.Store',
config: {
model: 'Sencha.model.Team',
autoLoad: true,
proxy: {
type: 'ajax',
actionMethods: {
create : 'POST',
read : 'POST', // by default GET
update : 'POST',
destroy: 'POST'
},
url: 'teams.json'
}
}
});
or define your own proxy class
Ext.define('Sencha.data.PostAjax', {
extend: 'Ext.data.proxy.Ajax',
alias: 'proxy.postproxy', // must to get string reference
config: {
actionMethods: {
create : 'POST',
read : 'POST', // by default GET
update : 'POST',
destroy: 'POST'
},
}
}
Ext.define('Sencha.store.Teams', {
extend: 'Ext.data.Store',
config: {
model: 'Sencha.model.Team',
autoLoad: true,
proxy: {
type: 'ajaxpost'
url: 'teams.json'
}
}
});
Disclaimer: code was written from scratch and not really tested. Please do not downvote if it does not work, before not get replay on your comment. Thanks.
本文介绍如何在ExtJS 4中配置Store以使用POST方法进行读取操作。通常,读取操作默认为GET请求,但有时可能需要通过POST发送数据。文章提供了两种方法:一是直接覆盖Store的actionMethods属性,二是定义自定义代理类。
1768





