EXTJS 3.2 几个最常用的高级store


    ExtJS的数据传输与处理配置相当麻烦,从Ext.data.Connection类到Ext.data.Record到Ext.data.Store,以及一系列proxy和Reader,往往让初学者很头疼。新学一样东西马上就去硬啃这些知识是非常不可取的,本人的经验是先用最简单的,等你熟练了再去深入理解其中的设计。

    还好ExtJS提供了几个用于处理数据传输的高级Store,在工作中非常实用:

  一:  Ext.data.SimpleStore

       可以认为:SimpleStore=Store+MemoryProxy+ArrayReader

      也就是说这个简洁版本的store专门用来处理返回为数组格式的数据。

      看如下代码:

....
   store : new Ext.data.SimpleStore({
                autoLoad : true,
	        url : __ctxPath + '/system/loadItemDictionary.do',
	        fields : ['proTypeId', 'typeName'],
		baseParams : {
		          itemName : label
			     }
			   }),
   ....

   指定url  指定fields  就可以一部请求后台数据,当然后台必须返回的苏数组格式的数据。很简单吧,这个store常用语表单中的下拉框取值。


二:Ext.data.JsonStore

    

this.store = new Ext.data.JsonStore({
		url : __ctxPath + "/communicate/listSmsMobile.do",
		root : "result",
	        totalProperty : "totalCounts",
		remoteSort : true,
		fields : [{
		name : "smsId",
		type : "int"}, "sendTime", "recipients", "phoneNumber","userId", "userName", "smsContent", "status"]});
		this.store.setDefaultSort("smsId", "desc");
		this.store.load({
				params : {
					start : 0,
					limit : 25
					}
				});

  JsonStore将JsonReader和HttpProxy整合在一起了,提供了一个从后台获取json数据的简便方法,分页也非常方便。

   后台返回标准的json数据既可以。


 三:Ext.data.GroupingJsonStore

    

this.store = new Ext.data.GroupingStore({
			proxy : new Ext.data.HttpProxy({
			url : __ctxPath + "/flow/nodesFieldRights.do?  defId="+ this.defId
			}),
			reader : new Ext.data.JsonReader({
				root : "result",
				id : "id",
				fields : [ {
					name : "rightId",
					type : "int"
				}, {
					name : "mappingId",
					type : "int"
				}, "taskName", {
					name : "readWrite",
					type : "int"
				}, {
					name : "refieldId",
					type : "int"
				}, "fieldName", "fieldLabel" ]
			}),
			groupField : "taskName"
		});
		this.store.load();

  上面的groupField标识按某一个字段进行分组显示

   




转载于:https://my.oschina.net/u/937697/blog/137583

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值