sathish
sathish

Reputation: 90

Sum of values in each column in a table in sapui5

Can we show the total sum value of a particular column at the bottom of the same column in sapui5. Here i'm using sap ui table.

Thanks, Sathish

Upvotes: 2

Views: 13486

Answers (3)

Nizar Bechir
Nizar Bechir

Reputation: 21

I got a very nice solution with sap.ui.table.Table.

Actually adding a footer was not effective because it display the control under the whole table. So What I did is playing with the multiLabels aggregation.

And here I got the Sum displayed under the headline directly.

enter image description here

Upvotes: 2

Recently I have come across similar issue, I have through lot of searches and came up with a solution for my scenario.

I have used Last Record as Total for all records and property fixedBottomRowCount="1".

Other Possible Solutions:

  1. Use Analaytical ALV, which has Total option
  2. Footer available at each column. I found this here, but have not verified the solution.

Upvotes: 1

Sunil B N
Sunil B N

Reputation: 4225

If you are using sap.ui.table.Table

You can use different controls like(grid/layouts) to align as per requirement.

//Create an instance of the table control
var oTable = new sap.ui.table.Table({
    title: "Table Example",
    //other attributes
      footer: new sap.ui.commons.Label({
         text:"1234"
       })
});

If you are using sap.m libraries:(RECOMMENDED)

Adding footer property will do that. footer is one of the aggregation.

aggregation: footer

cardinality : 0..1

type: sap.ui.core.Control

description: Control to be displayed in the column footer.

Sample code: (use object number instead of Label to differentiate number and currency)

new sap.m.Column({
    //hAlign: "Right", use if required
    header: new sap.m.Label({
        text: "Amount"
    }),
    footer: new sap.m.ObjectNumber({
        number: "{Total}",
        unit: "{CurrencyCode}",
        state: "Warning"
    })
});

Upvotes: 3

Related Questions