Announcement

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

    TreeGrid unsaved edits being blanked out by adding new nodes?

    Hello,

    I am running into an issue with a TreeGrid I am using. When I edit pre-existing nodes, and then add new nodes to the tree, the edits I had just made disappear. They simply are deleted from the records. Is this expected behavior, or a framework bug?

    I've worked around it by looping through the TreeGrid with the following code and storing all my edits into a map. Later, after adding new nodes to the TreeGrid, I restore the edits.

    Code:
                    int[] editRows = grid.getAllEditRows();
                    Map<Integer,Record>rowsToRestore = new HashMap<Integer,Record>();
                   
                    for (Integer i : editRows) {
                        rowsToRestore.put(i, grid.getEditedRecord(i));
                    }

    #2
    This is way too little information to be able to help.

    First, you haven't said what product or version your using.

    Then, cover what editing settings you're using, how the disappearing edits come to be (user edits? Programmatic editValues?), and show a series of requests and responses with the server that lead to dropped edits.

    Comment


      #3
      I am using the SmartGWT version v9.1p_2015-02-07/PowerEdition Deployment (built 2015-02-07)

      The edits can be either programmatic or from the user. Either way, they get blanked out from adding a large number of new nodes to the tree (it seems over 2 cause the bug). The nodes are added purely on the client side so there are no requests or responses that cause the problem. The following is a code example of where the problem occurs, including my workaround.
      Code:
      Map<Integer,Record>rowsToRestore = new HashMap<Integer,Record>(); //To work around what appears to be a framework bug
                      
      for (Integer i : editRows) { //To work around the blanking issue
        rowsToRestore.put(i, scheduleGrid.getEditedRecord(i));
      }
      
      for (Record r : allRecords) { //New records to add to the tree
         if (r.getAttribute("treeTitle") != null) {
            r.setAttribute("ItemOrder", r.getAttribute("treeTitle"));
         }
         TreeNode node = new TreeNode();
         node.setAttribute("tempId", tempId);
         tempId++;
                          
         tree.add(node, topNode); //This causes the blanking issue that blanks out all the edits
         addedNodes.add(node);
      }
      
                      
       for (Map.Entry<Integer, Record> entry : rowsToRestore.entrySet()) { //This for loop is part of the workaround
         Integer row = entry.getKey();
         Record recToRestore = entry.getValue();
         scheduleGrid.setEditValues(row.intValue(), recToRestore.toMap());
       }

      Comment


        #4
        It looks like the same as I described:
        http://forums.smartclient.com/forum/...es-to-database

        Comment


          #5
          That related thread is a usage issue (which we've explained in that thread), and the behavior described is different from what you report.

          Unfortunately we can't do anything with your short code sample since we have test cases that do the same thing, but work.

          As a next step you could try modifying one of the Tree-related samples to re-create your issue with standalone code that we can actually run. Then we'd be able to take a look.

          Comment

          Working...
          X