Search code examples
xmldatasourcesmartgwttreegrid

SmartGWT: TreeGrid expand empty folder resets the tree


I am building a TreeGrid with data from an XML type DataSource, as in SmartClient showcase.

I am using Windows XP and SmartGWT version 3.0, GWT SDK 2.4.0 (using Eclipse IDE).

However, the problem is when I try to expand an empty folder, the tree closes itself/resets and resetting all selections made to none (since i'm using a checkbox tree selection type), and also I got this error(warning):

[ERROR] [testtree] - 15:19:26.637:XRP0:WARN:ResultTree:isc_ResultTree_0 (created by: isc_TreeGrid_0):Adding node to tree with id property set to:1. A node with this ID is already present in this Tree - that node will be replaced. Note that this warning may be disabled by setting the reportCollisions attribute to false.

This is actually very much alike with this (http://forums.smartclient.com/showthread.php?t=20167), however he does not explain the solution. :(

This is the test values i use for the XML data source:

...
<record>
<id>1</id>
<parentId>0</parentId>
<name>test1</name>
</record>

<record>
<id>2</id>
<parentId>1</parentId>
<name>test41</name>
</record>

<record>
<id>3</id>
<parentId>2</parentId>
<name>test2</name>
</record>

<record>
    <id>4</id>
    <parentId>3</parentId>
    <name>test212</name>
</record>

This is the screenshot of the problem; (sorry not enough rep cannot post images) before I clicked the expand button: link (imgur image) and, after: link

According to the image above, this problem will occur if I try to expand 'test212', or 'test2'.

and this is the snippet of my TreeGrid properties:

...
TreeGrid test = new TreeGrid();
test.setAutoFetchData(true);
test.setDataSource(SingletonDS.getInstance());
test.setSelectionAppearance(SelectionAppearance.CHECKBOX);
test.setShowPartialSelection(true);
test.setShowSelectedStyle(false);

layout.addMember(test);

and this is the properties of my singleton DataSource:

...    
singleton.setDataFormat(DSDataFormat.XML);

singleton.setID("singletonDS");

DataSourceIntegerField idField = new DataSourceIntegerField("id", "ID");
idField.setPrimaryKey(true);
DataSourceIntegerField parentIdField = new DataSourceIntegerField("parentId", "Parent ID");
parentIdField.setForeignKey(singleton.getID()+".id");
parentId.setRootValue(0);
DataSourceTextField nameField = new DataSourceTextField("name", "Name");

singleton.setFields(idField, parentIdField, nameField);
...

Note: the XML data is already passed correctly into the grid.

Thanks for your help! :)


Solution

  • I think i have finally found the solution. This is no bug, it is my own clumsy fault.

    After debugging the project extensively I noticed that there is a idParent parameter in the GET parameters, and I didn't handle it. As a result, the servlet always outputs full XML data therefore producing this error.