extjs中store获取后台数据_请问我通过在做extjs时用json后台获取了一个数据,用store.on函数得到赋值给变量,但是怎么在函数外面得到store.on('load',function...

1 var ds = new Ext.data.Store({

2 proxy: new Ext.data.ScriptTagProxy({

3 url: 'yoururl.json'

4 }),

5 reader: new Ext.data.JsonReader({

6 root: 'Fields',

7 totalProperty: 'totalCount',

8 id: 'id'

9 }, [

10 ,

11

12 ])

13 });

14 var combobox = new Ext.form.ComboBox({

15 id:'combobox',

16 x:0,

17 y:20,

18 store: da,

19 displayField:'field',

20 typeAhead: false,

21 loadingText: '正在加载字段...',

22 forceSelection: false,

23 triggerAction: 'all',

24 hideTrigger:false,

25 minChars:1,

26 anchor: '100%',

27 pageSize:10

28 });

json输出

注意stcCallback1007要用程序输出请求过来的参数callback的值

stcCallback1007(,

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
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、付费专栏及课程。

余额充值