Announcement

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

    TreeGrid Reorder issue

    Hi Isomorphic,

    In Feature Explorer:
    http://www.smartclient.com/index.jsp#treeDropEvents
    I've put the following test code:
    Code:
    isc.TreeGrid.create({
        ID: "categoryTree",
        width: "100%",
        height: "100%",
        dataSource: "supplyCategory",   
        canAcceptDroppedRecords: true,
        canReorderRecords: true,
        canReparentNodes:false,     
        loadDataOnDemand: false,
        folderDrop : function  (dragRecords, dropFolder, index, sourceWidget)  {
           this.Super('folderDrop', arguments);
           isc.say(" index: "+index);
          }, 
        autoFetchData: true
    });
    In "Canteen and Washroom Products" try to reorder subcategories by dragging "Washroom" beneath "Canteen". Although folderDrop behaves as expected but visually the reordering dosen't happen.

    This is happening olny when I'm trying to reorder a node to the last position in his parent.


    Thanks,
    John

    #2
    canReorderRecords enables the reorder animation, but does not introduce a mechanism by which the order can be permanently stored (as would be required for a databound tree). To do this, save the index in the tree as a field on the record, and ensure you have the tree sorted on this index.

    Comment


      #3
      Hi Isomorphic,

      I'm not talking about that. I am talking about the fact that when I drag the child-node under the last child-node in the same parent the drag-node it's put above the last child-node and not below the last child-node. It's an issue of dragg'n'drop. I don't have an issue with the persistence of order.
      Please try the sample that I've provided.
      For a more obvious point of view try to reorder the children of "Office Furniture" by dragging "Large" under "Small". When the node is relaesed you'll notice that "Large" will be put above "Small" and not below it as it should.

      Thanks,
      John

      Comment


        #4
        Again, the cause of your issue is persistence and whether sort is maintained. Try it without a DataSource.

        Comment


          #5
          Ok, let me try another approach: why in all other cases the reoder works even with DataSource?
          I can reoder all the nodes but I only can't repositon a node as the last one. In my opinion this seems like a half job already done. Is it that hard to solve this issue when you've obviously already managed to get done most of it?


          Thanks,
          John

          PS: I;ve noticed from the start theat in nondatabound TreeGrids it's working but it's no use for a real life scenario.

          Comment


            #6
            The problem isn't half-solved, it's not solved at all - there is nowhere that the order is permanently stored. You're focusing on one manifestation of the problem and assuming that this is a bug to be fixed, in reality, there is the absence of a significant subsystem.

            So again:
            1. use a non-databound tree
            or
            2. implement a persistent order field and maintain the sort direction

            Comment


              #7
              The first approach I can't use it because I realy need a databound treegrid.
              The second approach means a full refetch of data from the server because the persistent order field changes for more than one record.

              However, here is my implementation of folderDrop. Can you kindly tell me if in the near future this could breake with the new versions of SmartClient?

              Code:
                  folderDrop : function  (dragRecords, dropFolder, index, sourceWidget)  {       
                     var tree = this.data;
                     var selectedNode = dragRecords[0];
              	   var parent = tree.getParent(selectedNode);
              	   var children = tree.getChildren(parent);				
              	   var childrenLength = children.getLength();	   
              	   var oldIndex = Number(children.indexOf(selectedNode));	   
                     this.Super('folderDrop', arguments);
              	   var needsRefresh = false;
              	   if(index<childrenLength) var newIndex = Number(children.indexOf(selectedNode));
              	   else {
              	       var newIndex = childrenLength - 1;
              		   needsRefresh = true;
              		}   
                     var interval = oldIndex-newIndex;
              	   if(interval!=0) {
                      var data = {grid:this.ID, entity:this.entity, node:selectedNode.id, interval:interval, needsRefresh:needsRefresh};
                      RPCManager.sendRequest({
                          params: data,
                          serverOutputAsString: true,
                          actionURL:CONTROLLER_DIR+"/index/reordertree",
                          callback: function(rpcResponse,data, rpcRequest) {
              							  var needsRefresh = rpcRequest.params.needsRefresh;
              							  if(needsRefresh) {
              							  var grid = eval(rpcRequest.params.grid);
                                            grid.invalidateCache();
                                            grid.fetchData(null, function(dsResponse, data, dsRequest) {grid.getData().openAll();});        							  
              							 } 
              						  }    
                      });
              	   }	
                    }
              Thanks in advance,
              John

              Comment


                #8
                This looks OK, although it seems like you should just update the affected nodes and sort() rather than invalidating cache and re-fetching.

                Comment

                Working...
                X