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 方法:

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方法的更多相关文章

  1. Extjs4 关于Store的一些操作(转)

    1.关于加载和回调的问题 ExtJs的Store在加载时候一般是延迟加载的,这时候Grid就会先出现一片空白,等加载完成后才出现数据:因此,我们需要给它添加一个提示信息! 但是Store却没有wait ...

  2. Extjs 动态修改gridPanel列头信息以及store数据的方法

    1 /*******************************checkbox按钮 历史报警信息**************************************/ var check ...

  3. app上传到App Store的快捷方法及步骤

    跳过证书的申请及配置概要文件的设置, 现在根据已有的配置概要文件及发布证书开始: 1.先在Xcode上的PROJECT和TARGETS->Build Setting->Code Signi ...

  4. EXTJS4自学手册——EXT基本方法、属性(mixins多继承、statics、require)

    1.mixins 说明:类似于面向对象中的多继承 <script type="text/javascript"> Ext.onReady(function () {// ...

  5. iOS APP版本更新跳转到App Store下载/更新方法

    使用下面的连接即可跳转到App Store itms-apps://itunes.apple.com/cn/app/id***********                  其中********* ...

  6. 【vue store的使用方法】(this.$store.state this.$store.getters this.$store.dispatch this.$store.commit)

    vue 页面文件 <template> <div> {{this.$store.state.count}}<br/> {{count}}<br/> {{ ...

  7. windows上传ipa到苹果开发者中(app store)的方法

    假如你已经使用过苹果开发者中心上架app,你肯定知道在苹果开发者中心的web界面,无法直接提交ipa文件,而是需要使用第三方工具,将ipa文件上传到构建版本,开发者中心才能在构建版本里选择构建版本上架 ...

  8. App Store常用推广方法

    转:http://www.cocoachina.com/bbs/read.php?tid-5000.html 天天潜水,在这里获益不少.不贡献一点似乎过意不去,所以在这里根据自己的经验谈谈基本的推广方 ...

  9. Extjs4中的store

      Extjs 4引入新的数据包,其中新增了不少新类并对旧有的类作出了修整.使数据包更强大和更容易使用.  本章我们将学习一下内容: 2.1. 概述新特性      Extjs4的数据包引入了如Mod ...

随机推荐

  1. Android OpenGL ES(一)----必备知识

    1.手机的坐标空间 我们都知道要想在手机上随心所欲的绘制图形,就必须了解手机的坐标体系.下图就是将坐标映射到手机屏幕的坐标. 图1手机屏幕基本坐标系 2.OpenGL基本图形 在OpenGL里,只能绘 ...

  2. HDU4268 Alice and Bob(贪心+multiset)

    Problem Description Alice and Bob's game never ends. Today, they introduce a new game. In this game, ...

  3. c#接口相关

    public interface I接口名 { void SaiHi(); void Hello(string msg); //以上是方法 string Name { get; set; } //以上 ...

  4. linux中重置服务器的mysql用户密码

    本文章前提条件是自己经把mysql登录密码给忘记了,这个时间我们解决方法有很多,重新安装mysql数据库一切重来,另一种是通过下面文章重新设置root密码,下面我们一起来看看方法二吧.     最 近 ...

  5. AMQ学习笔记 - 17. 事务的测试

    概述 对事务机制进行测试. 测试实例 测试实例 结果预测 发送正常 3条消息入队 发送异常 0条消息入队 接收正常 3条消息出队 接收异常 0条消息出队 demo设计 设计图 测试分工 测试类 测试方 ...

  6. 济南学习 Day 4 T1 pm

    幸运数字(number)Time Limit:1000ms Memory Limit:64MB题目描述LYK 最近运气很差,例如在 NOIP 初赛中仅仅考了 90 分,刚刚卡进复赛,于是它决定使用一些 ...

  7. POJ 1285 确定比赛名次

    Problem Description 有N个比赛队(1<=N<=500),编号依次为1,2,3,....,N进行比赛,比赛结束后,裁判委员会要将所有参赛队伍从前往后依次排名,但现在裁判委 ...

  8. 从malloc中窥探Linux内存分配策略

        malloc函数是C/C++中常用内存分配库函数,本篇文章将以Linux平台上的malloc为剖析对象,深入了解分配一块内存的旅程. malloc入门      使用malloc,需要包含头文 ...

  9. zedboard 构建嵌入式linux

    本文通过五部完成zedboard的嵌入式LINUX搭建,所谓磨刀不五砍材工嘛 1:系统环境搭建 要准备好交叉编译环境 见http://blog.csdn.net/xiabodan/article/de ...

  10. Ubuntu14.04 开启MySQL的remote access

    一旦开启MySQL的remote access, 即可实现在windows系统下连接ubuntu下的mysql 步骤如下: sudo vim /etc/mysql/my.cnf bind-addres ...