ExtJS - Grid panel not loaded with nested JSON

我们两清 提交于 2019-12-11 14:08:56

问题


Hello my JSON is: (formatted for better reading)

{"status":{"status":0,"msg":"Ok","protocolversion":"extjs.json"},
"list":[{"getLogfiles":[
{"key":"0","value":"...lugin\/monitor\/files\/x_worker_error.log"},
{"key":"1","value":"...les\/x-worker01-progress.log.1331769600"},
{"key":"2","value":"...\/application\/x\/plugin\/monitor\/files\/Test.log"},
{"key":"3","value":"...ind\/plugin\/monitor\/files\/logfile_for_navi_test.log"},
{"key":"4","value":"...lugin\/monitor\/files\/logfilefilter_worker_error.log"}]
}]
}

This json data is loaded successfully and I can print it on the console.log() but it is not loaded to my store:

    ...
   Ext.define( 'Xxx.plugins.monitor.store.GridLogfiles', {
      extend  : 'Ext.data.Store',
      mixins: [ 
         'Deft.mixin.Injectable'
      ],

      model: 'Xxx.plugins.monitor.model.GridLogfiles',

      proxy   : {
         type       : 'ajax',
         url        : 'xxx',
         extraParams: {
            user      : 'test',
            pass      : 'test',
            vers      : 'extjs.json',
            module    : 'monitor',
            func      : 'getLogfiles'
         },
         reader     : {
            type: 'json',
            root: 'list[0].getLogfiles',
            // root: 'list',
            successProperty:false
         } 
      }
     , autoLoad: true


   } );
...

I have tried both root: 'list' and root: 'list[0].getLogfiles

In console.log() the data is found under rawData (obj) -> list (array) -> 0 -> getLogfiles (array) -> 0, 1, 2 -> key, value

What is wrong? Thanks!


回答1:


So I fix it with:

root: 'list'

and changing Json to:

{"status":{"status":0,"msg":"Ok","protocolversion":"extjs.json"},"list":[{"key":"0","value":"...lugin\/monitor\/files\/logfilefilter_worker_error.log"},{"key":"1","value":"...les\/logfilefilter-worker01-progress.log.1331769600"},{"key":"2","value":"...\/application\/x\/plugin\/monitor\/files\/Test.log"},{"key":"3","value":"...ind\/plugin\/monitor\/files\/logfile_for_navi_test.log"},{"key":"4","value":"...lugin\/monitor\/files\/logfilefilter_worker_error.log"},{"key":"5","value":"...les\/logfilefilter-worker01-progress.log.1331769600"},{"key":"6","value":"...\/application\/x\/plugin\/monitor\/files\/Test.log"},{"key":"7","value":"...lugin\/monitor\/files\/logfilefilter_worker_error.log"},{"key":"8","value":"...les\/logfilefilter-worker01-progress.log.1331769600"},{"key":"9","value":"...\/application\/x\/plugin\/monitor\/files\/Test.log"}]}

and using Ext.create() instead of DeftJs inject: {}

Thanks for the help.



来源:https://stackoverflow.com/questions/10814654/extjs-grid-panel-not-loaded-with-nested-json

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