Skip to Content
Technical Articles

Sap.m.Column group rows / mergeDuplicates with mergeFunctionName method

mergeDucplicates is a powerful feature when used properly alongwith mergeFunctionName. we can use it to Group rows of information with the same values. That information can be text (by Using getText), images ((by Using getSrc) or formattedText (getHtmlText). But this can also be used to conditionally group items with the same value. For ex. if you want to merge names of the people with the same pernr.

 

Here is a plunkr for merging suppliers with the same category.

https://plnkr.co/edit/8uPeCHm7rNqwEyhSTtmY?p=preview

Not all the “Red Point Stores” are merged.  and also the “Titanium” entries are not merged too as they belong to a different categoty. Where as “Technocom” and  some of the “Red Point Stores” are merged.


 

<Column mergeDuplicates="true" mergeFunctionName="data#mergeKey" hAlign="Center">
   <header>
        <Text text="Supplier" />
   </header>
</Column>

 

<Text text="{SupplierName}" class="te xtStyle">
    <customData>
          <core:CustomData key="mergeKey" value="{SupplierName}+{Category}" />
     </customData>
</Text>

 

 

Define the customdatea with a key. give it the value you want to compare. use that key using the data#key to mergeFunctionName.

 

This is like calling Text control.data(“mergeKey”) which will return Supplier Name + Category.

Happy coding

 

 

1 Comment
You must be Logged on to comment or reply to a post.