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 ...
随机推荐
- C#自定义时间显示格式
string time = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); 下面是常见的一些日期时间显示格式 标准的For ...
- JavaScript之放大镜效果
在网上也浏览过许多关于JavaScript放大镜效果的文章,有的代码解释得些隐晦难懂,看的我头有点晕晕的╮(╯﹏╰)╭,我的心情是这样的: 吐槽完了,我们动动小鼠标,当鼠标经过下面这张美女图片时就实现 ...
- 从数据库里面取值绑定到Ztree
1.效果图(思路:将数据库表按照一定的格式排序,然后序列化成json字符串,绑定到Ztree上并显示出来) zTree v3.5.16 API 文档 :http://www.ztree.me/v3/a ...
- Linq连接数据库时,sql中的列为自增长,如何添加数据?
1`首先在数据库中写入命令 SET IDENTITY_INSERT 表名 on 2·重新把表拖入 .dbml 中
- HTML+CSS学习笔记 (13) - CSS代码缩写,占用更少的带宽
标签:HTML+CSS 盒模型代码简写 还记得在讲盒模型时外边距(margin).内边距(padding)和边框(border)设置上下左右四个方向的边距是按照顺时针方向设置的:上右下左.具体应用在m ...
- 分享10款功能强大的HTML5/CSS3应用插件
1.纯CSS3美化Checkbox和Radiobox按钮 外观很时尚 利用CSS3我们可以打造非常具有个性化的用户表单,今天我们就利用CSS3美化Checkbox复选框和Radiobox单选框.CSS ...
- hdu 3665 Seaside floyd+超级汇点
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3665 题意分析:以0为起点,求到Sea的最短路径. 所以可以N为超级汇点,使用floyd求0到N的最短 ...
- eclipse优化(部分)
1. 增强Eclipse(MyEclipse)输入代码提示功能 一般设置: (1). 打开Eclipse,选择打开" Window -- Preferences". (2). 在目 ...
- newsstand杂志阅读应用源码ipad版
一款newsstand iPad杂志阅读应用源码(newsstand在线下载/动态显示等)可以支持在线下载/动态显示等 ,也是一款newsstand iPad杂志阅读应用源码.运行之后,会在iPad ...
- 4_1 wp8数据绑定与独立存储空间[wp8特色开发与编程技巧]
Wp8数据绑定与独立存储空间 数据绑定为基于 Silverlight 的应用程序提供了一种显示数据并与数据进行交互的简便方法. 数据的显示方式独立于数据的管理. UI 和数据对象之间的连接或绑定使数据 ...