what is "root:'data' " extjs store config

393 views Asked by At

I am very new to ExtJs and I have the following code for a treeView,,which has a default root in the beginning and then an Ajax call to a servlet .But i don't understand the 'root' field with value 'data' .Is data an alias or xType .Here is the code:

   Ext.define('Eits.view.OrgTreeView', {
extend : 'Ext.tree.TreePanel',
requires: ['Eits.model.OrgTreeModel'],
    width : '100%',
    region : 'center',
    border : true,

    store : {
        xtype : 'tree',
        fields : Eits.model.OrgTreeModel.FIELDS,
        //model: 'Eits.model.OrgTreeModel',
        autoLoad: false,
        root: {
            id: 'rootNode',
            objectId : 'rootNode',
            leaf: false,
            expanded: false,
            text : 'MTS',
            iconCls : 'mts-Tree-Node',
        },
        proxy: {
            type: 'ajax',
            url: 'orgTree/getNavigationTree.action',
            actionMethods: 'POST',
            reader: {
                type: 'json',
                root: 'data'     
            }
        }
    }
1

There are 1 answers

0
CD.. On BEST ANSWER

root property is:

The name of the property which contains the data items corresponding to the Model(s) for which this Reader is configured. For JSON reader it's a property name (or a dot-separated list of property names if the root is nested). For XML reader it's a CSS selector. For Array reader the root is not applicable since the data is assumed to be a single-level array of arrays.

By default the natural root of the data will be used: the root JSON array, the root XML element, or the array.

The data packet value for this property should be an empty array to clear the data or show no data.

(Extjs's documentation is a great resource when using the framework)