Get data for Custom Group Footer

Posted by: fidori123456789 on 9 December 2019, 3:37 pm EST

  • Posted 9 December 2019, 3:37 pm EST - Updated 3 October 2022, 9:27 am EST

    Hello,

    I reference sample Custom Group Footer of FlexGrid follow link below.

    When I inserted Grid footer and symbol Ʃ, FlexGrid can inheritant data of Group Header.

    But I inserted Group footer can’t inheritant data from Aggregate column.

    Therefore, I hope can inheritant data when insert Group Footer.

    Can you show me the way get data for Custom Group footer ?

  • Posted 10 December 2019, 3:48 pm EST

    Hi,

    You will need to implement the itemFormatter callback and add the aggregates manually:

    In HTML:

    <wj-flex-grid 
                items-source="data"
                initialized="initGrid(s,e)"
                group-footers="true"
                item-formatter="formatter">
    </wj-flex-grid>
    

    In controller:

    $scope.formatter = function (panel, r, c, cell) {
            var row = panel.rows[r], col = panel.columns[c];
            if(col.aggregate === wijmo.Aggregate.None) {
                return;
            }
            if (panel.cellType === wijmo.grid.CellType.Cell && row instanceof wijmo.grid.GroupRow && row.cssClass === 'wj-groupfooter') {
                var group = findParentGroupRow(panel, row);
                cell.innerHTML = wijmo.Globalize.format(group.getAggregate(col.aggregate, col.binding), col.format);
            }
        };
    
        function findParentGroupRow(panel, row) {
            var idx = row.index - 1;
            while(idx-- >= 0) {
                var currentRow = panel.rows[idx];
                if(currentRow instanceof wijmo.grid.GroupRow && currentRow.level === row.level) {
                    return currentRow.dataItem;
                }
            }
        }
    

    You may refer to the sample attached.

    Regards,

    Ashwin

    CustomFooters.zip

  • Posted 10 December 2019, 11:26 pm EST - Updated 3 October 2022, 9:30 am EST

  • Posted 11 December 2019, 12:03 am EST

    Hello Ashwin,

    Thanks for your reply.

    When I run the sample with pagination. Althought, Data of SubGroup Footer is same SubGroup Header when use method group.getAggregate.

    But I have problem with set data of cell in Group Footer isn’t same Group Header because I don’t insert Group/SubGroup Footer,

    if Group don’t have enough Item. Therefore, I need get Total Data of Group Header at Previous Page then set data of Group Footer at next Page.

    I have send you the sample edit attached.

    Please see the picture below.

  • Posted 11 December 2019, 5:38 pm EST

    Hi,

    I understand your issue so I have asked the dev team to provide a workaround for this. The internal tracking id of the case is 412971. I will update you as soon as I will hear from them.

    ~regards

  • Posted 11 December 2019, 5:50 pm EST

    Thank you Ashwin,

    i will be waiting your reply.

    regards

  • Posted 12 December 2019, 7:50 pm EST

    Hi,

    I found a solution. In the getAggregate method, if you will provide the reference of the FlexGrid’s CollectionView, the data will be aggregated regardless of the current page. Please refer to the updated sample attached.

    ~regards

    CustomFooters_updated.zip

  • Posted 16 December 2019, 11:07 pm EST

    Thank you Ashwin,

    I resolved my problem for Group Footer , but I think can if SubGroup Footer can get data through method getAggregate the same Group ?

    ~ regard

  • Posted 17 December 2019, 4:47 pm EST

    Hi,

    Each of the custom footer row gets the aggregated data from the getAggregate method regardless of whether they are a main group footer or a sub group footer.

    Could you please explain more about the issue so that I can assist you accordingly.

    ~regards

  • Posted 18 December 2019, 2:32 pm EST

    Glad to be able to help.

    ~regards

  • Posted 19 December 2019, 7:50 pm EST - Updated 3 October 2022, 9:31 am EST

    Sorry for late reply ,

    I applied FlexGridPager class for FlexGrid appear some issue.

    Firstly, PageCount changed while manipulation into FlexGrid. Value of PageCount’s assign new value when collapse or expand a group or moveToPage …etc .

    Becasue my system get data from per page then I need static value of PageCount same mode data-level pagination of CollectionView.

    Secondly, I added GroupFooter and Output excel, i can’t see value of Group Footer in excel file. It had only value of Group Header.

    Can you show me the way get value of GroupFooter when Output excel !

    I have send you the sample CustomGroupFooter with FlexGridPager attached.

    Please see the picture below.

    That’s all.

    CustomFootersWithFlexGridPager__2.zip

  • Posted 22 December 2019, 7:44 pm EST

    Hi,

    Regarding changing of the number of pages:

    The FlexGridPager class does pagination on the grid level. Therefore, the pageCount changes as the number of rows in the FlexGrid changes and expanding/collapsing rows changes the number of rows. If you are using grid-level pagination, I would suggest you get all of the data at once and then apply paging.

    Regarding value not exporting to excel:

    The value on the group footer rows are not exporting to excel because we actually not setting the value in the grid rather than setting it as the innerHTML of the cell itself. You can use the setCellData method set the aggregate as the group footer value:

    $scope.formatter = function (panel, r, c, cell) {
        var row = panel.rows[r],
          col = panel.columns[c];
        // if no aggregate, then no need to run the formatter
        if (col.aggregate === wijmo.Aggregate.None) {
          return;
        }
        // check if row is group footer row
        if (
          panel.cellType === wijmo.grid.CellType.Cell &&
          row instanceof wijmo.grid.GroupRow &&
          row.cssClass === "wj-groupfooter"
        ) {
          // find the parent group
          var group = findParentGroupRow(panel, row).dataItem;
          var d = wijmo.Globalize.format(
            group.getAggregate(col.aggregate, col.binding, row.collectionView),
            col.format
          );
          panel.setCellData(r, c, d, false, false);
          cell.innerHTML = d;
        }
      };
    

    You can refer to the sample attached.

    ~regards

    CustomFooters.zip

Need extra support?

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

Learn More

Forum Channels