VAAA
VAAA

Reputation: 15039

ExtJS 6 how to set rootProperty of store

I have a store that uses a custom proxy.

Ext.define('MyApp.proxy.Proxy', {
    extend: 'Ext.data.proxy.Ajax',
    alias: 'proxy.myproxy',

    type: 'ajax',

    reader: {
        type: 'json',
        messageProperty: 'msg',
        rootProperty: 'data',
        totalProperty: 'num'
    }
});

How can I change the store rootProperty on code.

Right now Im using this:

 var storeMenu = Ext.create('MyApp.store.menu.Menu');

 storeMenu.proxy.reader.setRootProperty('data.items');

Is this the right way to do it?

Upvotes: 1

Views: 2004

Answers (1)

Mitchell Simoens
Mitchell Simoens

Reputation: 2536

rootProperty can also accept a function where you return the array you want to be parsed into records:

https://fiddle.sencha.com/#fiddle/1bo2

Upvotes: 1

Related Questions