1

I have a SAPUI5 table with numbers. I want to add a sum/total row to summarize the values of each column. I checked the documentation of both table classes:

as well as column classes:

but can't figure out if there is a standard column property, which specifies the sum of column values. I found several topics on SO regarding this subject, e.g.:

But none of them is marked as answered.

Is there any default column property, which can provide a total value of the column's data?

Mike
  • 14,010
  • 29
  • 101
  • 161

2 Answers2

4

sap.m.Column has an aggregation footer. You can place sap.m.Text with formatter there.

  <Table items="{path: '/customers'}">
    <columns>
      <Column><Text text="Name" /></Column>
      <Column>
        <Text text="Amount" />
        <footer><Text text="{path: '/customers', formatter: '.sumAmount'}" /></footer>
      </Column>
    </columns>
    <items>
      <ColumnListItem>        
        <cells>
          <Text text="{name}" />
          <Text text="{amount}" />
        </cells>
      </ColumnListItem>        
    </items>
  </Table>
Annie W.
  • 328
  • 4
  • 22
1

No, there is no property like this available with the controls you are looking at. As also mentioned in the posts you have referred, you will have to do this with javascript calculation and then you can use the footer to bind and show the sum (example for reference)

Nonetheless, this can be achieved simply with Fiori Analytical table sap.ui.table.AnalyticalTable

more about analytical table

Let me know if this helps!

Nandan Chaturvedi
  • 1,028
  • 3
  • 16
  • 32
  • I checked `sap.ui.table.AnalyticalTable`, it looks like `sumOnTop` is deprecated since 1.44. Do you have any sample with the usage of `sumOnTop` successor? – Mike Nov 06 '18 at 13:56
  • In the SAP documentation regarding the ALV (experience.sap.com/fiori-design-web/analytical-table-alv), it is written: _"The property: sumOnTop shows additional aggregation values on the group header, even if the group is expanded. *Do not use it*."_ Do you now why it is recommended to avoid it? – Mike Nov 07 '18 at 08:26