I've noticed a problem in the TreeGrid, since I upgraded to smartgwt-1.1.
I couldn't find any troubles in the Showcase, so I've isolated the problem I'm having into the following code snippets:
The data for my TreeGrid is coming from the server via GwtRpcDataSource, but for the sake of simplicity, this is a simulation without RPC calling involved:
These two pieces of code run perfectly on smartgwt-1.0b2 (see attached screenshot).
With smartgwt-1.1 I get the following exception:
What exactly is happening here?
Thanks!
I couldn't find any troubles in the Showcase, so I've isolated the problem I'm having into the following code snippets:
Code:
public class TreeGridDemo implements EntryPoint { public void onModuleLoad() { createTreeGrid().draw(); } private TreeGrid createTreeGrid() { TreeGrid treeGrid = new TreeGrid(); treeGrid.setLeaveScrollbarGap(true); treeGrid.setLoadDataOnDemand(false); treeGrid.setWidth(500); treeGrid.setHeight(400); treeGrid.setShowOpenIcons(false); treeGrid.setShowDropIcons(false); treeGrid.setClosedIconSuffix(""); treeGrid.setAutoFetchData(true); treeGrid.setFields(new TreeGridField("caption", "Book Catalog")); treeGrid.setDataSource(CatalogDS.getInstance()); return treeGrid; } }
Code:
public class CatalogDS extends GwtRpcDataSource { private static CatalogDS instance = null; public static CatalogDS getInstance() { if (instance == null) { instance = new CatalogDS(); } return instance; } public CatalogDS() { setID("CatalogDS"); setTitleField("Caption"); DataSourceTextField captionField = new DataSourceTextField("caption", "Caption"); DataSourceTextField keyField = new DataSourceTextField("key", "Key"); keyField.setPrimaryKey(true); keyField.setRequired(true); DataSourceTextField parentKeyField = new DataSourceTextField("parentKey", "Parent Key"); parentKeyField.setRequired(true); parentKeyField.setForeignKey("CatalogDS.key"); parentKeyField.setRootValue("catalogRoot"); setFields(captionField, keyField, parentKeyField); } @Override protected void executeAdd(String requestId, DSRequest request, DSResponse response) { // not supported } @Override protected void executeFetch(String requestId, DSRequest request, DSResponse response) { ListGridRecord[] data = createTestData(); response.setData(data); response.setTotalRows(data.length); response.setStatus(RPCResponse.STATUS_SUCCESS); processResponse(requestId, response); } @Override protected void executeRemove(String requestId, DSRequest request, DSResponse response) { // not supported } @Override protected void executeUpdate(String requestId, DSRequest request, DSResponse response) { // not supported } private static ListGridRecord[] createTestData() { ListGridRecord[] records = new ListGridRecord[6]; records[0] = createCatalogRecord("catalogRoot", "", "Book Catalog"); records[1] = createCatalogRecord("author1", "catalogRoot", "Enrique Vila-Matas"); records[2] = createCatalogRecord("book1", "author1", "Montano's Malady"); records[3] = createCatalogRecord("author2", "catalogRoot", "Thomas Bernhard"); records[4] = createCatalogRecord("book2", "author2", "Extinction"); records[5] = createCatalogRecord("book3", "author2", "Old Masters"); return records; } private static ListGridRecord createCatalogRecord(String key, String parentKey, String caption) { ListGridRecord record = new ListGridRecord(); record.setAttribute("key", key); record.setAttribute("parentKey", parentKey); record.setAttribute("caption", caption); return record; } }
With smartgwt-1.1 I get the following exception:
Code:
java.lang.ClassCastException: com.smartgwt.client.widgets.grid.ListGridRecord at com.smartgwt.client.widgets.tree.TreeNode.getOrCreateRef(TreeNode.java:69) at com.smartgwt.client.widgets.BaseWidget.draw(Native Method) at org.demos.client.TreeGridDemo.onModuleLoad(TreeGridDemo.java:11)
Thanks!
Comment