Rally Software

  • 1.  Calculated Column in Custom TreeGrid

    Posted Nov 14, 2017 03:56 PM

    I am creating a custom app in Rally (Agile Central) using the TreeGrid.  I create a grid fine but I want to create a column of a calculated value - a percentage based on 2 fields and use the PortfolioItemPercentDoneTemplate to render the value (to get the percent complete bar).

     

    I have done this several times with a Custom Store and regular grid but has anyone succeeded with a calculated column in a TreeGrid?



  • 2.  Re: Calculated Column in Custom TreeGrid

    Posted Nov 15, 2017 09:05 AM

    corkr03 or morky01 have you had any success with something like this?

     

    Thanks!

     

    Michael



  • 3.  Re: Calculated Column in Custom TreeGrid
    Best Answer

    Posted Nov 15, 2017 09:41 AM

    The last time I added a derived column to a tree grid about a year ago (in this app), it was not a straightforward task and I had to use brute force and overrides to get the desired result.  

     

    The general approach was this:

    1.  Calculate the "derived field(s)" and add them to the models on the store load event (note that this is fired every time a treegrid node is expanded and may contain many different record types).   

     

    For example: 

       gridBoardStore.on('load', this._updateDerivedFields, this); 

     

    In the _updateDerivedFields method, make your calculation and add it to the model.  

     

    _updateDerivedFields: function(records){

          _.each(records, function(r){

                 r.set('myDerivedField', someValue);

          });

    }

     

    Or see the updateDerivedColumns method in src\javascript\app.js file at the link provided below for an example. 

     

    2.  There were several overrides I had to make in the treegrid to prevent these fields (and columns) from being removed from the treeStore and treegrid when the grid is refreshed.  See the src\javascript\utils\overrides.js file in the link provided below. 

     

    3.  I added these derived columns as a separate config on the gridConfig of the gridboard (see addGridBoard function in the app.js file). The overrides in the file in #2 mentioned above also takes care of making sure these columns don't get filtered out.  In the case of the example file, these columns were not available in the field picker and were always rendered.  

     

    I hope this helps.  morky01 may know of a more elegant approach.

     

    Kristy   



  • 4.  Re: Calculated Column in Custom TreeGrid

    Posted Nov 15, 2017 11:45 AM

    Yuck.  Thanks for your answer corkr03!  I remember you were fighting this awhile ago and that it ended up being fairly gross.  I don't understand why this is so hard with the tree grid, when it's so easy and painless with the regular flat grid.  ChristopherSheridan1340048 do you definitely need the hierarchy?  If so, the above is probably the way to go...