什么是 "root:'data' " extjs 存储配置
what is "root:'data' " extjs store config
我是 ExtJs 的新手,我有以下树视图代码,它在开始时有一个默认根,然后是对 servlet 的 Ajax 调用。但我不明白'root' 值为 'data' 的字段。数据是别名还是 xType。这是代码:
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'
}
}
}
root
属性 是:
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 的文档是使用该框架时的重要资源)
我是 ExtJs 的新手,我有以下树视图代码,它在开始时有一个默认根,然后是对 servlet 的 Ajax 调用。但我不明白'root' 值为 'data' 的字段。数据是别名还是 xType。这是代码:
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'
}
}
}
root
属性 是:
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 的文档是使用该框架时的重要资源)