Hi, I’ m new of SmartGWT. First of all, you made a great good work, thanks.
I’ m faceing some problems with TreeGrid and GWTRPC call.
My goal:
Server side I have a set of data loaded from DB. The dates have id, name, id of father.
Client side I want to rapresent this datas inside to TreeGrid. I read the topic on the forum but unfortunatly I did’t finde the solution.
This is my code.
public class ImageViewer implements EntryPoint {
private VStack container;
private SourceMy dataS;
private ServerCallAsync serverInterface;
public void onModuleLoad() {
serverInterface = (ServerCallAsync) GWT.create(ServerCall.class);
String pathServer = GWT.getModuleBaseURL() + "ServerCall";
((ServiceDefTarget) serverInterface).setServiceEntryPoint(pathServer);
container = new VStack();
dataS=SourceMy.getInstance();
MyTreeGrid();
Button load=new Button("Load");
load.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
AsyncCallback<ArrayList<NodeObj>>callback=new AsyncCallback<ArrayList<NodeObj>>() {
@Override
public void onSuccess(ArrayList<NodeObj> result) {
}
@Override
public void onFailure(Throwable caught) {
}
};
serverInterface.getTypeServer(callback);
}
});
container.draw();
}
private void MyTreeGrid(){
TreeGridField fieldName = new TreeGridField("Name");
typeTree = new TreeGrid();
typeTree.setWidth(500);
typeTree.setHeight(250);
typeTree.setDataSource(dataS);
typeTree.setCanEdit(true);
typeTree.setFields(fieldName);
container.addMember(typeTree);
The SourceMy class:
public class SourceMy extends DataSource{
private static SourceMy instance = null;
public static SourceMy getInstance() {
if (instance == null) {
instance = new SourceMy("type");
}
return instance;
}
public SourceMy(String id) {
setID(id);
DataSourceTextField idField = new DataSourceTextField("Id", "Id", 128);
idField.setPrimaryKey(true);
idField.setHidden(true);
DataSourceTextField fatherField = new DataSourceTextField("Father", "Father", 128);
DataSourceTextField nameField = new DataSourceTextField("Name", "Name", 128);
nameField.setForeignKey("Father");
setFields(idField,nameField,fatherField);
setClientOnly(true);
}
}
May you tell me some suggestions? Are 2 days that I’m traing to resolve this problem.