• If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Announcement

Collapse
No announcement yet.

[HELPED] running total in grid column?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • [HELPED] running total in grid column?

    If you wanted to have a running total grid column based on the amounts in another column, couldn't you use a renderer function in the running total grid column?

    COLA..........COLB (running total)
    100.00.......100.00
    100.00.......200.00
    100.00.......300.00
    350.00.......650.00
    etc
    etc

    this is close, but I have something wrong... Or is there a better/easier way to do it?
    Code:
    renderer: function(value, metaData, record, row, col, store, grid) {   
    var cumulativeAmt = 0;
    for (i = 0; i < store.data.items.length; i++) {
       cumulativeAmt += record.get('COLA');
       if( i >= (row-1)){
          return Ext.util.Format.usMoney(cumulativeAmt);
        }
    }  
    }

  • #2
    Can you try adding up the count and storing it in a field in the storeload listener instead of the grid renderer?

    Comment


    • #3
      adding a count??? i'm not following..sorry

      Comment


      • #4
        on storeload
        var total = 0;
        for each record in store
        total += yourField;
        set running total field = total;

        Makes sense?

        Comment


        • #5
          it does. I can try that... thanks!

          Comment

          Working...
          X