cancel
Showing results for 
Search instead for 
Did you mean: 

sap.m.Table Summing up a column value

mantrishekar
Active Participant
0 Kudos

Hello All,

I have sap.m.Table with 10 Columns.

Now in that one column is Total Resultant Loss and another is Resultant Loss.

Now i want to display summed up value in Total Resultant Loss.

This sum should be done based on condition i,e if the column has same loss types and units should be summed up together and displayed in the first column and remaining columns should be empty.

Please find the attached Screen shot for more information.

Regards,

Shekar.

Accepted Solutions (0)

Answers (3)

Answers (3)

neha_thapa2
Explorer
0 Kudos

Hi Shekar,

Did you find any solution. I have the same requirement.

mantrishekar
Active Participant
0 Kudos

Hi Neha,

See the above requirement you referring to is done in Native HANA Application.

Finally at that time not aware of CDS Views,i have done the logic in UI Itself using Array, and as it is done long ago am not able to recall it.

Regards,

Shekar.

Caspar_van_t
Explorer
0 Kudos

Hi Mantri,

Sorry, I was not aware your table was grouped.

So far, this is not possible in SAPUI5 on a standard way.

The only thing that is possible, is to display a footer in a column, which will be at the bottom of the table.

If this is not what you need, but you need it per group, you'll have to custom build something.

Greets,

Caspar

mantrishekar
Active Participant

Hi Caspar,

Thanks for your response.

If you find any solution in mean time Please let me know.

Regards,

Shekar.

Caspar_van_t
Explorer
0 Kudos

Hi Shekar,

The calculation will have to be done in code, best is to loop through your model and place the found values in a new JSON model, then bind it to your sum-controls.

To display the sum of a column correctly, you can use a column footer, like so:


<Column minScreenWidth="Tablet" demandPopin="true" hAlign="Left" width="4em">

  <Text text="{i18n>TableLabelUsed}"/>

  <footer>

  <Text text="{path: 'MockModelTotals>/LeaveTotalsLegalLeaveTableUsed', formatter:'hrstamgegevens.model.formatter.floatValue'}"/>

  </footer>

  </Column>

Then it will display a footer, that shows the sum of the values.

I hope this suits your scenario

Greets,

Caspar

PS: Check out this link for more info, and a JS example: Sum of values in each column in a table in sapui5 - Stack Overflow

mantrishekar
Active Participant
0 Kudos

Hello Casper,

My requirement is to Sum up for only single column.

But in that single column i need to add the values for specific Group.This is some thing siimilar to adding the values in items in a sales order.

Here i need to sumup Total Loss Unit Column for every group and teh added value should only be displayed in first Row of the event.