Fliegend的乱七八糟空间

新手入门,Hello World!

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

在日常使用store获取远程数据时,经常遇到需要远程接口返回的数据并不是直接就是前端需要的,或者希望在返回store数据的同时,返回其他相关数据,此时可以在store获取返回值时直接在store内部针对数据进行一次处理。

在配置reader时支持transform可传递一个方法,方法返回值为实际写入store的数据。
 var myStore = Ext.create('Ext.data.Store', {
     model: 'User',
     proxy: {
         type: 'ajax',
         url: '/users.json',
         reader: {
           type: 'json',
           transform: {
             fn: function(data) {
                   // do some manipulation of the raw data object
                 return data;
                },
              scope: this
              }
          }
     },
     autoLoad: true
 });

 

posted on 2021-04-22 10:39  Fliegend  阅读(300)  评论(0)    收藏  举报