Sum of values in each column in a table in sapui5

2019-07-20 17:16发布

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

标签: sapui5
3条回答
虎瘦雄心在
2楼-- · 2019-07-20 17:56

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.
查看更多
太酷不给撩
3楼-- · 2019-07-20 18:02

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"
    })
});
查看更多
不美不萌又怎样
4楼-- · 2019-07-20 18:08

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

查看更多
登录 后发表回答