Announcement

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

    TreeGrid and DataSource

    SmartClient Version: SNAPSHOT_v9.1d_2013-12-17/PowerEdition Deployment (built 2013-12-17)

    IE8

    I have a TreeGrid which does periodical refreshes using the underlying dynamic DataSource. I saw the posting on the Wiki about periodical refreshing using a ListGrid and DataSource, so I adopted that approach to my TreeGrid. No more ResultTree ID clashes in the devmode log, great.

    My TreeGrid.DataArrived handler no longer is triggered using a DataSource.fetch(criteria, DSCallback). Also my SortNormalizer used in my TreeGrid is no longer being applied.

    Code:
    DataSource treeGridDataSource = treeGrid.getDataSource();
    treeGridDataSource.invalidateCache();
    treeGridDataSource.fetchData(criteria, new DSCallback() {
                    @Override
                    public void execute(DSResponse dsResponse, Object data, DSRequest dsRequest) {
    
                        Tree newTree = new Tree();
                        newTree.setRootValue(0);
                        newTree.setModelType(TreeModelType.PARENT);
                        newTree.setIdField("id");
                        newTree.setParentIdField("pid");
                        
    
                        Record [] recordList = dsResponse.getData();
                        TreeNode[] nodeList = new TreeNode[recordList.length];
    
                        for(int m=0; m<recordList.length; m++){
                            nodeList[m] = new TreeNode(recordList[m].getJsObj());
                        }
    
                        newTree.setData(nodeList);
                        treeGrid.setData(newTree);
                    }
                });
    Is there something I need to do to get the TreeGrid DataArrived handler and SortNormalizer working again?
    Last edited by JLivermore; 14 Feb 2014, 08:41. Reason: added more detail

    #2
    My SortNormalizer is working fine.

    Is there a way to get the TreeGrid's DataArrivedHandler to execute when in the DSCallback I do the TreeGrid.setData()?
    Last edited by JLivermore; 14 Feb 2014, 09:21.

    Comment


      #3
      No, you cannot manually trigger DataArrived. You should simply call the same logic from your DSCallback.

      By the way: yes it's expected that DataArrived would not fire in this circumstance. The TreeGrid isn't away of the data fetch going on, and when the new dataset is provided via setData(), it doesn't know where you got the data, so has no idea if something "arrived" or not.

      Comment


        #4
        So if the TreeGrid is not aware of new data being set via TreeGrid.setData() what kinds of things should I be aware of?

        Comment


          #5
          ?

          All we said is that when you call setData(), the TreeGrid is not in a position to fire a DataArrived event, because it doesn't know where the data is from. It could be locally created dummy data, previously cached data etc. So it would be incorrect for the TreeGrid to fire a DataArrived event, and you should instead simply call whatever logic you need to right after you call setData().

          Comment


            #6
            Sorry, let me rephrase that, if DataArrived event is not fired, CellFormatter or HoverCustomizer be affected?

            Comment


              #7
              No, no other events are effected.

              Comment

              Working...
              X