ExtJS - Grid panel not loaded with nested JSON

2019-09-03 10:17发布

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条回答
甜甜的少女心
2楼-- · 2019-09-03 10:41

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.

查看更多
登录 后发表回答