I am using the example :
http://www.smartclient.com/smartgwt/showcase/#tree_interaction_drag_nodes
but changed the datasource to XML file and now its not working.
The XML used is :
<RootNode>
<ChildNode>
<ChildID>2</ChildID>
<Name>ChildNode1</Name>
<ReportsTo>1</ReportsTo>
</ChildNode>
<ChildNode>
<ChildID>3</ChildID>
<Name>ChildNode1.1</Name>
<ReportsTo>2</ReportsTo>
</ChildNode>
<ChildNode>
<ChildID>4</ChildID>
<Name>ChildNode2</Name>
<ReportsTo>1</ReportsTo>
</ChildNode>
<ChildNode>
<ChildID>5</ChildID>
<Name>ChildNode2.1</Name>
<ReportsTo>4</ReportsTo>
</ChildNode>
<ChildNode>
<ChildID>6</ChildID>
<Name>ChildNode2.1.1</Name>
<ReportsTo>5</ReportsTo>
</ChildNode>
</RootNode>
whereas for grid1 and grid2 i am changing the datasources to the xml file as follows :
Instead of :
grid1.setData(grid1Tree);
grid1.getData().openAll();
I am using :
grid1.setAutoFetchData(true);
grid1.setDataSource(EmployeeXmlDS.getInstance());
grid1.draw();
And similarly for grid2. And here is the EmployeeXmlDS implementation :
import com.smartgwt.client.data.DataSource;
import com.smartgwt.client.data.fields.DataSourceIntegerField;
import com.smartgwt.client.data.fields.DataSourceTextField;
public class EmployeeXmlDS extends DataSource {
private static EmployeeXmlDS instance = null;
public static EmployeeXmlDS getInstance() {
if (instance == null) {
instance = new EmployeeXmlDS("employeesDS");
}
return instance;
}
public EmployeeXmlDS(String id) {
setID(id);
setTitleField("Name");
setRecordXPath("/RootNode/ChildNode");
DataSourceTextField nameField = new DataSourceTextField("Name", "Name", 128);
DataSourceIntegerField childIdField = new DataSourceIntegerField("ChildID", "Child ID");
childIdField.setPrimaryKey(true);
childIdField.setRequired(true);
DataSourceIntegerField reportsToField = new DataSourceIntegerField("ReportsTo", "Parent");
reportsToField.setRequired(true);
reportsToField.setForeignKey(id + ".ChildID");
reportsToField.setRootValue("1");
setFields(nameField,childIdField,reportsToField);
setDataURL("ds/test_data/tree2.xml");
setClientOnly(true);
}
}
Please help.