Announcement

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

    How to trigger createRecordComponent() on TreeGrid's leafs?

    I am using one of the older nightly builds but I doubt this is a bug, it seems I may be doing something wrong.

    I updated SmartGWT to the last night's build and the same problem exists.
    We are on SmartGWT Pro 3.1d 10/03/12.
    Isomorphic, I am totally stuck and could really use some advice, it is rather urgent that I figure this out.

    I have a TreeGrid, I set setShowRecordComponents(true) and setShowRecordComponentsByCell(true). The data in that TreeGrid is a copy being created by Drag and Drop from another TreeGrid. Essentially, only a parent element is being dragged - that works just fine and recordcomponents are all created succesfully. As soon as parent record is dropped, I call RPC services from addFolderDropHandler. RPC queries the data which is then brought into the TreeGrid using treeGrid.getTree().linkNodes(treeNodes);

    The tree is rendered as it's supposed to with proper parent/child linking. What is not happening is that children that are retrieved using RPC do not invoke createRecordComponent(). I tried invalidateRecordComponents() to no avail. Something makes these new leafs different from the parent records.

    Code:
    TreeGrid surrenderTreeGrid = new TreeGrid() {
      @Override
      protected Canvas createRecordComponent(final ListGridRecord listGridRecord, Integer colNum) {
          String fieldName = this.getFieldName(colNum);
    
           if(fieldName.equalsIgnoreCase("myField")){
                return new Canvas();
           }
    
           return null;
      }
    }
    
    surrenderTreeGrid.setCanAcceptDroppedRecords(true);
    surrenderTreeGrid.setShowRecordComponents(true);
    surrenderTreeGrid.setShowRecordComponentsByCell(true);
    
    
    surrenderTreeGrid.addFolderDropHandler(new FolderDropHandler() {
        @Override
         public void onFolderDrop(FolderDropEvent folderDropEvent) {
             // calling RPC here, actual call removed
             // onSuccess() body 
             {
                      TreeNode[] treeNodes = new TreeNode[rpcMessage.recs.size()];
                      int i = 0;
                      for( looping over return results ) {
                               TreeNode treeNode = new TreeNode();
                               treeNode.setAttribute()....;
                               treeNodes[i] = treeNode;
                                i++;
                        }
                        surrenderTreeGrid.getTree().linkNodes(treeNodes);
              }
         }
    });
    Thanks,
    Henry
    Last edited by hlevin; 3 Oct 2012, 15:27. Reason: Updated to the latest build and still have this problem

    #2
    Same issue on 3.1d-2012-10-03. is this an expected behavior or a bug?

    Comment


      #3
      Found the problem, it was in my own code as I expected. I had stub code that was aborting createRecordComponet() and returning null. It was a needle in a haystack.

      Comment

      Working...
      X