PDA

View Full Version : Loading Ext.tree.TreePanel question



robhyx
7 Jan 2011, 10:15 AM
Hi all, is it possible to load a TreePanel with a Ext.data.Store and call store.loadData(data) asynchronously? I have several GridPanels that load data this way and for this one data set I'd like to see the data displayed as a tree.

This is typically how I load data into my GridPanel:



var record = Ext.data.Record.create([
{name: 'firstName'},
{name: 'lastName'},
{name: 'phoneNumber'},
{name: 'emailAddress'},
{name: 'clipboard_cbx'}
]);

this.reader = new Ext.data.JsonReader({
root: "list" // The property which contains an Array of row objects
}, record);

var store = new Ext.data.Store({
reader: this.reader
});

var refresh = function(){
object.getContacts(function(data){
if(!data || data.length == 0){
throw 'refresh():Error getting data from the server';
}
store.loadData(data);
});
};
var grid = new Ext.grid.GridPanel({
store: store,

cm: new Ext.grid.ColumnModel([
{align: 'left', header: 'First Name', sortable: true, dataIndex: 'firstName'},
{align: 'left', header: 'Last Name', sortable: true, dataIndex: 'lastName'},
{align: 'left', header: 'Phone Number', sortable: true, dataIndex: 'phoneNumber'},
{id: 'emailAddress', align: 'left', header: 'Email Address', sortable: true, dataIndex: 'emailAddress'}
]),
//other init params...
});



Is there a way to load a TreePanel similarly?