我创建了一个树形面板,然后创建store
了
var store = Ext.create('Ext.data.TreeStore', {
autoload: false,
proxy: {
type: 'ajax',
url: 'data.php',
reader: {
type: 'json',
root: 'results'
}
}
});
我的服务器打印 json 看起来像
{ "results":
[
{ id : '1' , text : '1', expanded: true,
children :[
{ id : '5' , text : '5', leaf:true},
{ id : '6' , text : '6', leaf:true}
]
},
{ id : '2' , text : '2', leaf:true},
{ id : '3' , text : '3', leaf:true},
{ id : '4' , text : '4', leaf:true},
{ id : '7' , text : '7', leaf:true},
{ id : '8' , text : '8', leaf:true},
{ id : '9' , text : '9', leaf:true},
{ id : '10' , text : '10', expanded: true,
children :[
{ id : '11' , text : '11', leaf:true},
{ id : '12' , text : '12', leaf:true}
]
}
]
}
但是当我运行我的代码时,我看到了萤火虫并且它总是运行GET http://localhost/example/data.php...
永不停止:(
我的树加了很多倍
怎么解决 谢谢
编辑
实际上,我用别名定义了我的树形面板并将其用作xtype
但是我创建了新示例并遇到了同样的问题。这是我的js
var store = Ext.create('Ext.data.TreeStore', {
autoload: false,
proxy: {
type: 'ajax',
url: 'data.php',
reader: {
type: 'json',
root: 'results'
}
}
});
Ext.create('Ext.tree.Panel', {
title: 'Simple Tree',
width: 200,
height: 150,
store: store,
rootVisible: false,
renderTo: Ext.getBody()
});
这是我的data.php
echo "
{
'success': true,
'variable': 100,
'results':
[
{ id : '1' , text : '1', expanded: true,
children :[
{ id : '5' , text : '5', leaf:true},
{ id : '6' , text : '6', leaf:true}
]
},
{ id : '2' , text : '2', leaf:true},
{ id : '3' , text : '3', leaf:true},
{ id : '4' , text : '4', leaf:true},
{ id : '7' , text : '7', leaf:true},
{ id : '8' , text : '8', leaf:true},
{ id : '9' , text : '9', leaf:true},
{ id : '10' , text : '10', expanded: true,
children :[
{ id : '11' , text : '11', leaf:true},
{ id : '12' , text : '12', leaf:true}
]
}
]
}";