Extjs4.2.1 - Laden von json in das Treepanel schlägt fehl
Ich erstelle ein Treepanel und ich und erstellestore
mögen
var store = Ext.create('Ext.data.TreeStore', {
autoload: false,
proxy: {
type: 'ajax',
url: 'data.php',
reader: {
type: 'json',
root: 'results'
}
}
});
Mein Server Print Json sieht aus wie
{ "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}
]
}
]
}
Aber wenn ich meinen Code starte, sehe ich Firebug und das läuft immerGET http://localhost/example/data.php...
niemals aufhören :(
und mein Baum wird so sehr verdoppelt
Wie man das behebt, danke
Bearbeiten
In der Realität definiere ich mein Treepanel mit Alias und benutze es alsxtype
Aber ich erstelle ein neues Beispiel und bekomme das gleiche Problem. Hier ist mein 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()
});
Und hier ist meinedata.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}
]
}
]
}";