extjs4 – 从ajax商店读取ExtJS消息

前端之家收集整理的这篇文章主要介绍了extjs4 – 从ajax商店读取ExtJS消息前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我有一个带有ajax代理和json阅读器的ExtJS商店: @H_301_2@Ext.create('Ext.data.Store',{ proxy: { type: 'ajax',url: '...',reader: { type: 'json',root: 'data',totalProperty: 'totalCount',messageProperty: 'message',successProperty: 'success' },...

这是我从服务器获得的:

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

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

解决方法

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

UPDATE

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

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

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

猜你在找的Ajax相关文章