ExtJS: Getting response of Proxy post in local variable

此生再无相见时 提交于 2019-12-24 02:42:48

问题


I am new to ExtJS so please excuse if this is very basic. I googled but couldn't find any useful answer.

I have a Store with proxy type AJAX:

tableStore = Ext.create('Ext.data.Store', {
               model: 'TableData',
               pageSize: 20,
               proxy: {
                   type: 'ajax',
                   url: url
               }
});

The call to url returns a JSON object. I want to get this JSON object in some local variable to do some processing.

Is this possible?

Thanks.


回答1:


You can refer to the data obtained in the method transform:

Ext.define('MyModel', {
extend: 'Ext.data.Model',
fields: [
    {name: 'id', type: 'int'}
    , {name: 'title', type: 'string'}
]
, proxy: {
    type: 'rest'
    , reader: {
        type: 'json'
       , transform: {
            fn: function (data) {
                //you code here
                return data;
            }
            , scope: this
        }
    }
}});



回答2:


try with this

   tableStore.getProxy().getReader().rawData 


来源:https://stackoverflow.com/questions/27403915/extjs-getting-response-of-proxy-post-in-local-variable

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!