PDA

View Full Version : How to use TreePanel with JSON



TrojanMyth
30 May 2012, 6:20 AM
Dear All;

I want to use treepanel for my menu and i used treestore for my treepanel;

My ModelType

ModelType t = new ModelType();
t.setRoot("dataset");
t.addField("title","title");
t.addField("icon","icon");

MyStore

public abstract class TreeDataSet<M extends ModelData> extends TreeStore<M> {


protected RpcProxy<String> RPCProxy;
protected ScriptTagProxy<String> ScriptTagProxy;
protected JsonLoadResultReader<List<M>> LoadResultReader;
protected ModelType Model;


public TreeDataSet(RpcProxy<String> proxy, ModelType Type) {
super();
this.RPCProxy = proxy;
this.Model = Type;
LoadResultReader = new JsonLoadResultReader<List<M>>(Model);
loader = new BaseTreeLoader<M>(RPCProxy, LoadResultReader) {


@Override
public boolean hasChildren(M parent) {
return TreeDataSet.this.hasChildren(parent);
}
};
listen();
}
}

but this code is create loaderException and ClassCastException com.extjs.gxt.ui.client.data.BaseListLoadResult .. cast java.util.List


​how can i solve this problem. Thanx