从json格式读取时发生Extjs treepicker错误
我对Extjs还是新手。我有一个TreeStore,它读取JSON字符串作为输入,我可以在树面板中表示它。但当我尝试在树选择器中使用树存储时,出现以下错误: 这里少了什么东西吗从json格式读取时发生Extjs treepicker错误,extjs,extjs-stores,Extjs,Extjs Stores,我对Extjs还是新手。我有一个TreeStore,它读取JSON字符串作为输入,我可以在树面板中表示它。但当我尝试在树选择器中使用树存储时,出现以下错误: 这里少了什么东西吗 // try to find a record in the store that matches the value record = value ? me.store.getNodeById(value) : me.store.getRootNode(); 以下是JSON格式: { succes
// try to find a record in the store that matches the value
record = value ? me.store.getNodeById(value) : me.store.getRootNode();
以下是JSON格式:
{
success: true,
"children": [
{
"id": "G_1",
"text": "group1",
"leaf": false
},
{
"id": "G_2",
"text": "group2",
"leaf": false
}
]
}
这是我的树顶:
Ext.define('App.store.GroupTree', {
extend: 'Ext.data.TreeStore',
model: 'App.model.GroupTree',
requires: 'App.model.GroupTree',
proxy: {
type: 'ajax',
url: 'property/tree.json',
reader: {
type: 'json',
root:'children'
}
},
});
我的treepicker项目:
items: [
{
xtype: 'treepicker',
name: 'propertyCmb',
fieldLabel: 'Property',
labelWidth: 60,
displayField: 'text',
store: 'GroupTree',
valueField: 'id',
queryMode: 'local',
}
]
这是treestore模型代码
Ext.define('App.model.GroupTree', {
extend: 'Ext.data.Model',
fields: [
{name: 'id', type: 'string', useNull: true},
{name: 'text', type: 'string'},
{name: 'leaf', type: 'boolean'},
{name: 'expanded', type: 'boolean'}
]
});
出现错误的原因是,当分配给类似treepicker的存储时,存储不是自动创建的:“GroupTree”。 您必须首先创建它的一个实例,该实例需要分配给treepicker。请参阅文档 以下几点应该有效
var groupStore = Ext.create('App.store.GroupTree');
groupStore.load();
var picker = Ext.create('Ext.ux.TreePicker',{
name: 'propertyCmb',
store: groupStore,
fieldLabel: 'Property',
labelWidth: 60,
displayField: 'text',
valueField: 'id',
queryMode: 'local',
renderTo: Ext.getBody()
});
可以在上找到工作小提琴。请同时提供App.model.GroupTree的代码。这个错误是发生在您的代码中还是ExtJs的代码中?我在问题的末尾添加了它,它是ExtJs错误