Extjs4 使用store的post方法
Extjs4 使用store的post方法
引用官网的一句话
Now when we call store.load(), the AjaxProxy springs into action, making a request to the url we configured ('users.json' in this case). As we're performing a read, it sends a GET request to that url (see actionMethods to customize this - by default any kind of read will be sent as a GET request and any kind of write will be sent as a POST request).
我们点进去看看它源码:
Ext.define('Ext.data.proxy.Ajax', {
requires: ['Ext.Ajax'],
extend: 'Ext.data.proxy.Server',
alias: 'proxy.ajax',
alternateClassName: ['Ext.data.HttpProxy', 'Ext.data.AjaxProxy'],
/**
* @property {Object} actionMethods
* Mapping of action name to HTTP request method. In the basic AjaxProxy these are set to 'GET' for 'read' actions
* and 'POST' for 'create', 'update' and 'destroy' actions. The {@link Ext.data.proxy.Rest} maps these to the
* correct RESTful methods.
*/
actionMethods: {
create : 'POST',
read : 'GET',
update : 'POST',
destroy: 'POST'
},
// Keep a default copy of the action methods here. Ideally could just null
// out actionMethods and just check if it exists & has a property, otherwise
// fallback to the default. But at the moment it's defined as a public property,
// so we need to be able to maintain the ability to modify/access it.
defaultActionMethods: {
create : 'POST',
read : 'GET',
update : 'POST',
destroy: 'POST'
},
... ... ...
}
到这里,我想你的思路也很清晰了.具体做法如下
1.覆盖 actionmathods 方法:
1.覆盖 actionmathods 方法:
Ext.define('Sencha.store.Users', {
extend: 'Ext.data.Store',
config: {
model: 'Sencha.model.Users',
autoLoad: true,
proxy: {
type: 'ajax',
actionMethods: {
create : 'POST',
read : 'POST', // by default GET
update : 'POST',
destroy: 'POST'
},
url: 'teams.json'
}
}
});
var mystore = Ext.create('Ext.data.Store', {
// 分页大小
pageSize : 20,
model : 'mydata',
storeId : 'mystore',
proxy : {
type : 'ajax',
actionMethods : {
create : 'POST',
read : 'POST', // by default GET
update : 'POST',
destroy : 'POST'
},
url : mj.basePath + 'service/user!datagrid.cy',
reader : {
root : 'leafData',
totalProperty : 'totalRows'
}
},
sorters : [ {
property : 'createTime', // 排序字段
direction : 'desc'// 默认ASC
} ]
})
2. 覆盖 defaultActionMethods 方法:
var mystore = Ext.create('Ext.data.Store', {
// 分页大小
pageSize : 20,
model : 'mydata',
storeId : 'mystore',
proxy : {
type : 'ajax',
defaultActionMethods : {
create : 'POST',
read : 'POST', // by default GET
update : 'POST',
destroy : 'POST'
},
url : mj.basePath + 'service/user!datagrid.cy',
reader : {
root : 'leafData',
totalProperty : 'totalRows'
}
}
3. 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'
}
}
});
参考资料: http://blog.csdn.net/henriezhang/article/details/8978919
Extjs4 使用store的post方法的更多相关文章
- Extjs4 关于Store的一些操作(转)
1.关于加载和回调的问题 ExtJs的Store在加载时候一般是延迟加载的,这时候Grid就会先出现一片空白,等加载完成后才出现数据:因此,我们需要给它添加一个提示信息! 但是Store却没有wait ...
- Extjs 动态修改gridPanel列头信息以及store数据的方法
1 /*******************************checkbox按钮 历史报警信息**************************************/ var check ...
- app上传到App Store的快捷方法及步骤
跳过证书的申请及配置概要文件的设置, 现在根据已有的配置概要文件及发布证书开始: 1.先在Xcode上的PROJECT和TARGETS->Build Setting->Code Signi ...
- EXTJS4自学手册——EXT基本方法、属性(mixins多继承、statics、require)
1.mixins 说明:类似于面向对象中的多继承 <script type="text/javascript"> Ext.onReady(function () {// ...
- iOS APP版本更新跳转到App Store下载/更新方法
使用下面的连接即可跳转到App Store itms-apps://itunes.apple.com/cn/app/id*********** 其中********* ...
- 【vue store的使用方法】(this.$store.state this.$store.getters this.$store.dispatch this.$store.commit)
vue 页面文件 <template> <div> {{this.$store.state.count}}<br/> {{count}}<br/> {{ ...
- windows上传ipa到苹果开发者中(app store)的方法
假如你已经使用过苹果开发者中心上架app,你肯定知道在苹果开发者中心的web界面,无法直接提交ipa文件,而是需要使用第三方工具,将ipa文件上传到构建版本,开发者中心才能在构建版本里选择构建版本上架 ...
- App Store常用推广方法
转:http://www.cocoachina.com/bbs/read.php?tid-5000.html 天天潜水,在这里获益不少.不贡献一点似乎过意不去,所以在这里根据自己的经验谈谈基本的推广方 ...
- Extjs4中的store
Extjs 4引入新的数据包,其中新增了不少新类并对旧有的类作出了修整.使数据包更强大和更容易使用. 本章我们将学习一下内容: 2.1. 概述新特性 Extjs4的数据包引入了如Mod ...
随机推荐
- VpnService
这段时间项目中使用到了VpnService,整理了一下官方文档的资料 VpnService is a base class for applications to extend and build t ...
- IOS NSNotificationCenter 的使用
在Android中,为了解耦各个模块的耦合度,我们会使用很多方式,当然最简单而且效率最高的方式就是使用事件总线的方式进行消息分发,但是Android中并没有自带的消息分发机制,需要使用第三方库,比如E ...
- 使用MSBUILD 构建时出错 error MSB3086: Task could not find "sgen.exe" using the SdkToolsPath的解决方法
如果项目有添加有WB引用,比如引用其它网站的WEB服务等,那么VS在编译时会自动生成个 [项目名称].Serializers.dll的文件,就是把引用服务中的相关对象信息生成硬编码的程序集,以提高效率 ...
- UIView的frame的扩展分类,轻松取出x、y、height、width等值
一.引言: 在ios开发中,就界面搭建.控件布局时,都会很恶心的通过很长的代码才能取出控件的x.y.height.width等值,大大降低了开发效率.那为了省略这些恶心的步骤,小编在这里给UIView ...
- Apple Watch开发之界面之间的正向传值
主要分两种,一种是故事板中通过segue进行的传值,第二种是使用代码. 贴代码 24行代码是代码进行传值 35是故事板中的
- hdu 2501 Tiling_easy version 递推
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2501 题目分析:已知有2*1,2*2,两种型号的瓷砖,要求铺满2*n的格子有多少种方法.可以考虑最左边 ...
- change
#include<iostream> using namespace std; int main() { double a; cin>>a; cout<<a< ...
- 简单工厂(Simple Pattern)模式
一.简单工厂(Simple Factory)模式 Simple Factory 模式根据提供给它的数据,返回几个可能类中的一个类的实例.通常它返回的类都有一个公共的父类和公共的方法. Simple F ...
- 《RHEL6硬盘的分区和swap分区管理》——硬盘分区的大总结
首先介绍下几个简单的命令: free查看当前系统内存的使用情况 查看分区的使用情况:T类型.H显示大小以G,M 查看系统所有硬盘的分区信息:分区的没分区的都显示出来了 开始分区:为什么要加cu 不加 ...
- ADO.NET笔记——使用Command执行增删改操作,通过判断ExecuteNonQuery()返回值检查是否操作成功
相关知识: ExecuteNonQuery()方法:执行CommandText属性所制定的操作,返回受影响的记录条数.该方法一般用来执行SQL中的UPDATE.INSERT和DELETE等操作 对于U ...