tags:

views:

44

answers:

1

I have json :

{"files":[{"name":"1","size":"329"},{"name":"Spring","size":"153"},],"path":"C:\Programs"}

and store with jsonReader

var fileListStore = new Ext.data.Store({
    proxy: new Ext.data.HttpProxy(connection),
    baseParams: {
        path: '',
        action: ''
    },
    storeId: 'fileListStore',
    autoLoad: true,
    remoteSort: true,
    reader: new Ext.data.JsonReader({
    root: 'files',
    fields: [
        'name',
        'size'
        ]
    })
});

How have I change jsonReader to get json property 'path'? And how can I print it?

A: 

If by "print" you mean to display the path with each record then you are better off simply duplicating it into each record when you generate the JSON data and dealing with any messy details in the grid's column renderers.

If you must still have the path be its own root-level property then you can add a listener for your HttpProxy's load event and use it to read the JsonReader's jsonData property:

new Ext.data.HttpProxy({
    listeners: {
        load: function( proxy, req ) {
            window.alert(req.reader.jsonData.path);
        }
    }
});
owlness