加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

extjs4 – 从ajax商店读取ExtJS消息

发布时间:2020-12-15 22:56:31 所属栏目:百科 来源:网络整理
导读:我有一个带有ajax代理和json阅读器的ExtJS商店: Ext.create('Ext.data.Store',{ proxy: { type: 'ajax',url: '...',reader: { type: 'json',root: 'data',totalProperty: 'totalCount',messageProperty: 'message',successProperty: 'success' },... 这是我
我有一个带有ajax代理和json阅读器的ExtJS商店:
Ext.create('Ext.data.Store',{
    proxy: {
        type: 'ajax',url: '...',reader: {
            type: 'json',root: 'data',totalProperty: 'totalCount',messageProperty: 'message',successProperty: 'success'
        },...

这是我从服务器获得的:

data: [...]
message: "I want to read this string after the store is loaded"
success: true
totalCount: x

现在我想在加载商店时访问“消息” – 我从哪里获得它?我看了很多,但我找不到一个可以挂钩的地方?代理中唯一的侦听器是异常,这对我没有帮助.

解决方法

使用商店 load活动:
Ext.create('Ext.data.Store',{
  listeners: {
    'load': function(store,records,successful,operation) {
      alert(operation.resultSet.message);
    }
  },proxy: {
  // ...

UPDATE

似乎加载事件的文档是错误的.正确的参数列表是(存储,记录,成功)(无操作参数).因此上述解决方案无效.

但是有读者的rawData属性可以帮助:

Ext.create('Ext.data.Store',successful) {
      alert(store.getProxy().getReader().rawData.message);
    }
  },proxy: {
  // ...

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读