Retrieve Group Row Data

Posted by: hoang.nguyen on 31 August 2018, 8:10 pm EST

    • Post Options:
    • Link

    Posted 31 August 2018, 8:10 pm EST

    If I have a data collection of:

    Name, Address, City, State, Zip Code, Score1, Score2, Diff

    I have group them by: Name, City, State

    I have aggregate by Sum on Score1, Score2

    s.columns[j].aggregate = ‘Sum’;

    By default, the total will display on GroupRow Score1 and Score2

    Now I need to set cell text of GroupRow on Diff = Score1 - Score2

    I am trying to apply this to a FlexGrid. How can I do it? Thank you very much.

  • Posted 3 September 2018, 2:00 am EST

    Hi,

    You may use the formatItem event to fulfil the given requirement.

    Please refer to the following code snippet:-

    grid.formatItem.addHandler((s,e)=>{
          if(e.panel.cellType == wjcGrid.CellType.Cell && e.panel.rows[e.row].hasChildren && e.panel.columns[e.col].binding=="diff"){
            let score1 = e.panel.getCellData(e.row, e.panel.columns.getColumn('score1').index);
            let score2 = e.panel.getCellData(e.row, e.panel.columns.getColumn('score2').index);
            let diff = score1 - score2;
            e.cell.innerHTML = diff;
          }
        });
    

    You may also refer to the following sample for the full implementation:-

    https://stackblitz.com/edit/angular-3noaof?file=app%2Fapp.component.ts

    ~Sharad

  • Posted 3 September 2018, 9:46 am EST

    Thank you Sharad very much

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels