Announcement

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

    Add root node to TreeGrid with GwtRpcDataSource

    I'm using TreeGrid with GwtRpcDataSource. If I add node by TreeGrid.addData() method as child of some existing node, everything is OK, data are saved to database and node appears in TreeGrid. But if i add node this way as root node, node doesn't appear in TreeGrid, but is saved to database.

    What can be wrong?

    I found some related topic in this forum, where it seems like bug:
    http://forums.smartclient.com/showthread.php?t=2960

    I have SmartGWT 1.2 with GWT 1.7.

    Thanks a lot
    Last edited by jojky; 9 Sep 2009, 06:33.

    #2
    The same issue with SmartGWT 2.0.1.

    Comment


      #3
      Not a core SmartGWT problem (try the samples), look into problems with GWTRPCDataSource or your own code.

      Note you can enable the ResultTree log in the Developer Console to debug problems like this.

      Comment


        #4
        I have same problem

        my code for add operation:
        Code:
        			public void onSuccess(String result) {
        				ListGridRecord[] list = new ListGridRecord[1];
        				ListGridRecord updRec = new ListGridRecord(JSON.decode(result));
        				list[0] = updRec;
        				response.setData(list);
        				response.setStatus(RPCResponse.STATUS_SUCCESS);
        				processResponse(requestId, response);
        				System.out.println(result);
        			}});
        it works well for ListGrid.

        for add Child data,it has a good performance.
        Code:
                    public void onClick(MenuItemClickEvent event) {
        				String id = getTreeGrid().getSelectedRecord().getAttribute("id");
        				Map<String, String> map = new HashMap<String, String>();
        				map.put("parentid", id);
        				getTreeGrid().startEditingNew(map);
                    }
        but for add root data ,the new record will disappear.
        when I refresh the tree, the data has been saved to database.
        the code for client add root data:
        Code:
        getTreeGrid().startEditingNew();
        result in onSuccess() is:
        {"address":"","fname":"5","id":"402881e5262c0d1a01262c0fccc20004","parentid":"","phonenum":"","shortname":"5"}

        what's wrong? thank you!

        Comment


          #5
          same issue for me

          First of all, thank you for putting together an amazing library! I'm stunned.

          However, I'm experiencing the exact same issues as described above (similar to this http://forums.smartclient.com/showthread.php?t=9072). Adding new children to nodes other than the root works flawlessly - adding new root nodes, calls the exact same functionality on the server, updates the server side, return the same type of object as in the other cases only having the rootValue as the parentId ("-1"), still does not seem to update the tree, even though the debugged ResultTree reports without errors

          Code:
          15:37:52.161:INFO:ResultTree:isc_ResultTree_8 (created by: isc_OID_1):Updating cache: operationType 'add', 1 rows update data:
          [
          {__ref: com.example.records.OrganizationUnitListGridRecord@27,
          _canEdit: true,
          isFolder: true,
          canDrag: true,
          canAcceptDrop: true,
          name: "new unit",
          parentId: "-1",
          typeId: "293",
          id: "293"}
          ]
          The id and parent field for the datasource is defined as follows
          Code:
          DataSourceField idField = new DataSourceIntegerField(ID, "ID");
          idField.setPrimaryKey(true);
          idField.setRequired(true);
          ...
          
          DataSourceField parentIdField = new DataSourceIntegerField(PARENT_ID, "Parent"); // parentId, as above
          parentIdField.setForeignKey(DATASOURCE_ID + "." + ID);
          parentIdField.setRootValue(TOP_LEVEL_NODE); // the string "-1"
          ...
          Client code to add the node

          Code:
          ListGridRecord record = new ListGridRecord();
          record.setAttribute(NAME, "default name");
          record.setAttribute(PARENT_ID, TOP_LEVEL_NODE);
          			
          unitsTreeGrid.addData(record, new DSCallback() {
          				
          	public void execute(DSResponse response, Object rawData, DSRequest request) {
          		// this gets called
          	}	
          });
          The returned record from the server has a unique id, parentId (equal to the rootValue, equal to "-1") , and a name, like shown in the first piece of code. This is also the case for all other nodes that are added, that works, for all parentId's except "-1" (e.g., "256", "257"..)

          Still no cigar. Any ideas appreciated!

          Best regards,
          marduc
          Last edited by marduc; 22 Feb 2010, 07:07.

          Comment


            #6
            Always post all relevant versions (see the FAQ).

            Most likely, you have a case sensitivity problem in your field names, such as "parentId" vs "parentID". They must match on case.

            Comment


              #7
              Sorry about that, I am using gwt 2.0 with smartgwt 2.0, in firefox 3.5 on windows xp.

              I'm not experiencing any developer console warnings or errors, nor any javascript errors - this is in normal mode, not the hosted mode.

              I double checked the case sensitivity problem you suggested, but found that I refer the constant PARENT_ID (i.e., "parentId") in all cases. I stress that the code used to add nodes, to the root, or any other node (that works), is the same in either case.

              Other suggestions are appreciated!

              Comment


                #8
                What all posters here have in common is the use of GWTRPCDataSource. We have samples and automated tests showing this functionality works with a variety of other DataSource types.

                Look for something in GWTRPCDataSource that is modifying the rootValue or otherwise interfering with the data or metadata involved in tree loading.

                Comment


                  #9
                  Solved

                  After trying practicly everything I checked out the nightly build (what I probably should have tried even before asking..) and the problem seems to have gone away :)

                  If its possible, I would love for you to point me in the general direction as to where such a change in the smartclient codebase may have happened, so that I (if its not a huge change) can try comparing the revisions and patch my own version of the stable release of smartgwt - while happily awaiting the next!

                  Best regards,
                  torgeir

                  Comment

                  Working...
                  X