Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    TreeGrid w/ DataSource broken in Dev Mode

    Hello,

    First of all, thank you for SmartGWT! It's been a slick and flexible way for me to write pretty advanced and good-looking GUIs!

    I'm posting now with a problem I've encountered in Dev Mode when trying to draw a TreeGrid that is bound to a DataSource. I have my own client-only DataSource to which I addData() by creating TreeNode objects and defining their property values. (For my project, I want the root of the Tree to be some value that is less than 1 or is not an Integer; I would prefer a null value for convenience.)

    As it is I get the "Loading Data..." message in the TreeGrid and an unspecific error message on the stderr console of my IDE: "Uncaught JavaScript exception [Exception thrown and not caught] in http://localhost:8080/Ticketer/gwt/Workbench/hosted.html?Workbench, line 281". The sample code posted below renders fine if I compile and run without Dev Mode. It also works in Dev Mode if I refactor the TreeGrid/TreeGridField/TreeNode objects to ListGrid/ListGridField/ListGridRecord.

    Am I missing something? Have I done something stupid? Thanks for taking a look!

    Code:
    public class TreeGridDatasourceTest extends VLayout {
    
        public TreeGridDatasourceTest() {
            TreeGrid grid = new TreeGrid();
            grid.setSize("125px", "100px");
            grid.setLeaveScrollbarGap(false);
    
            TreeGridField idField = new TreeGridField("TicketID", "Ticket ID");
            TreeGridField parentField = new TreeGridField("ParentID", "Parent ID");
            grid.setFields(idField, parentField);
    
            MyDS ticketDS = new MyDS("tickets");
            TreeNode node1 = new TreeNode();
            node1.setAttribute("TicketID", 1);
            /*Integer nullParent = null;
            node1.setAttribute("ParentID", nullParent);*/
            TreeNode node2 = new TreeNode();
            node2.setAttribute("TicketID", 2);
            node2.setAttribute("ParentID", 1);
            ticketDS.addData(node1);
            ticketDS.addData(node2);
    
            grid.setDataSource(ticketDS);
            grid.setAutoFetchData(true);
            this.addMember(grid);
        }
    
        private class MyDS extends DataSource {
    
            public MyDS(String id) {
                super(id);
                setClientOnly(true);
                DataSourceIntegerField ticketId = new DataSourceIntegerField("TicketID", "Ticket ID");
                ticketId.setPrimaryKey(true);
                DataSourceIntegerField parentId = new DataSourceIntegerField("ParentID", "Parent ID");
                parentId.setForeignKey("TicketID");
    
                setFields(ticketId, parentId);
            }
        }
    }

    #2
    The TreeNode title needs to be a String, not a number. So change to call node1.setAttribute("TicketID", "1") instead. I have however updated SVN to handle this case by converting the title to a String if the user data has it as a number.

    btw which version of GWT and Smart GWT are you using? With GWT 2.x and Smart GWT 2.1 exception handling is much better and I got a pretty useful stacktrace pointing to the issue.

    Sanjiv

    Comment


      #3
      Thanks, again, Sanjiv! I have changed the TicketID attribute to a String value and the TreeGrid renders correctly!

      I am using GWT 2.0.3 and SmartGWT 2.0, I will upgrade to SmartGWT 2.1 immediately!

      Comment

      Working...
      X