从new Ext.data.Store取得从后台传到前台的值

  //工种
    var dataStore1 = new Ext.data.Store({             //定义数据集,用于存放树的结点信息    
 			proxy: new Ext.data.HttpProxy({
 				url: 'serviceAction!getserviceinfo.shtml'     //ROOT_PARENTCODE直接使用,默认为0
 			}),
 			reader: new Ext.data.JsonReader({root: 'list'},
 				[	
 	                {name: 'remark'}      //depDesc
 	                
 	            ]),	
 			remoteSort: true,
 			autoLoad: {params:{start:PAGING_START_INDEX,limit:PAGING_PAGE_SIZE}} //设置分页参数

 		});	
         dataStore1.load();	   //加载数据集
         
         dataStore1.on('load',function(){
        	 alert("adfsdfds");
        	 alert(dataStore1.getAt(0).get("remark"));
        	 
        
         });


Ext.data.Store 类是 ExtJS 中用于管理数据的核心类之一,它提供了从后台获取数据、本地缓存数据、数据筛选和排序等功能。下面介绍一下 Ext.data.Store后台获取数据的几种方式。 1. Ajax 请求方式 可以通过在 Store 的 proxy 配置中设置 type 为 ajax,然后配置 url、method、params 等参数来发送 Ajax 请求,从后台获取数据。示例代码如下: ``` Ext.create('Ext.data.Store', { proxy: { type: 'ajax', url: 'your_url', method: 'GET', params: { // 请求参数 }, reader: { type: 'json', rootProperty: 'data' } }, autoLoad: true, fields: [ // 字段定义 ] }); ``` 2. JsonP 请求方式 可以通过在 Store 的 proxy 配置中设置 type 为 jsonp,然后配置 url、callbackKey 等参数来发送 JsonP 请求,从后台获取数据。示例代码如下: ``` Ext.create('Ext.data.Store', { proxy: { type: 'jsonp', url: 'your_url', callbackKey: 'callback', reader: { type: 'json', rootProperty: 'data' } }, autoLoad: true, fields: [ // 字段定义 ] }); ``` 3. Restful 请求方式 可以通过在 Store 的 proxy 配置中设置 type 为 rest,然后配置 url、reader、writer 等参数来发送 Restful 请求,从后台获取数据。示例代码如下: ``` Ext.create('Ext.data.Store', { proxy: { type: 'rest', url: 'your_url', reader: { type: 'json', rootProperty: 'data' }, writer: { type: 'json' } }, autoLoad: true, fields: [ // 字段定义 ] }); ``` 4. WebSocket 请求方式 可以通过在 Store 的 proxy 配置中设置 type 为 websocket,然后配置 url、reader、writer 等参数来发送 WebSocket 请求,从后台获取数据。示例代码如下: ``` Ext.create('Ext.data.Store', { proxy: { type: 'websocket', url: 'your_url', reader: { type: 'json', rootProperty: 'data' }, writer: { type: 'json' } }, autoLoad: true, fields: [ // 字段定义 ] }); ``` 需要注意的是,以上不同类型的请求方式需要根据后台接口的实际情况进行选择和配置。同时,在 Store 的 fields 配置中也需要定义从后台获取的数据字段。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值