cancel
Showing results for 
Search instead for 
Did you mean: 

Merging duplicates in SAPUI5 m.table

3,511

Hi, I have encountered a problem with my m.table where if i group the first column of my table, it will group the entire table with the 1st cell as shown below;

I added the group:true to my sorter which created headers (which is what it should do but don't need want the headers in the table) and that has merged the table correctly.

I have included my xml code and json code.

	<Table id="quickViewTable" visible="true" class="tableView middleView testing sapUiResponsiveMargin" width="60%"
								items="{ path:'/results', sorter: { path: 'date', group: true} }" noDataText="{worklistView>/tableNoDataText}"
								busyIndicatorDelay="{worklistView>/tableBusyDelay}" growing="true" growingThreshold="15" growingScrollToLoad="true"
								mode="SingleSelectMaster" updateFinished="onUpdateFinished" selectionChange="onHistoryTableSelected">
								<items>
									<ColumnListItem counter="0">
										<cells>
											<ObjectIdentifier title="{ path:'date'}"></ObjectIdentifier>
											<ImageContent src="{ path:'product' }" class="quickProduct">
											
											</ImageContent>
											<ImageContent src="{ path:'room' }" class="quickRoom">
												
											</ImageContent>
										</cells>
									</ColumnListItem>
								</items>
								<columns>
									<Column id="hRe1ason" mergeDuplicates="true">
										<header>
											<Text text="Date"/>
										</header>
									</Column>
									<Column id="hRea1sonDesc" minScreenWidth="Tablet">
										<Text text="Product"/>
									</Column>
									<Column id="h1Ct" minScreenWidth="Tablet">
										<Text text="Room"/>
									</Column>
								</columns>
							</Table>

JSON functionality

loadAppointments: function (oEvent) {
			var quickViewTable = this.getView().byId("quickViewTable");
			quickViewTable.setVisible(true);
			var quickViewTableOrders = this.getView().byId("quickViewTableOrders");
			quickViewTableOrders.setVisible(false);
			var jsonData = {
				"results": [{
					"date": "2 Months Ago",
					"product": "./images/awn.png",
					"room": "./images/kitchen-furniture.png"
				}, {
					"date": "2 Months Ago",
					"product": "./images/flo.png",
					"room": "./images/dining-room.png"
				}, {
					"date": "4 Months Ago",
					"product": "./images/pyt.png",
					"room": "./images/lounge.png"
				}, {
					"date": "4 Months Ago",
					"product": "./images/conSides.png",
					"room": "./images/bedroom.png"
				}, {
					"date": "6 Months Ago",
					"product": "./images/crt.png",
					"room": "./images/bathroom.png"
				}, {
					"date": "6 Months Ago",
					"product": "./images/bxr.png",
					"room": "./images/house.png"
				}, {
					"date": "7 Months Ago",
					"product": "./images/plt.png",
					"room": "./images/other.png"
				}, {
					"date": "8 Months Ago",
					"product": "./images/rob.png",
					"room": "./images/house.png"
				}, {
					"date": "9 Months Ago",
					"product": "./images/rom.png",
					"room": "./images/house.png"
				}, {
					"date": "9 Months Ago",
					"product": "./images/shu.png",
					"room": "./images/house.png"
				}, {
					"date": "9 Months Ago",
					"product": "./images/ven.png",
					"room": "./images/house.png"
				}, {
					"date": "11 Months Ago",
					"product": "./images/vet.png",
					"room": "./images/house.png"
				}]
			}


			var quickModel = new sap.ui.model.json.JSONModel();
			quickModel.setData(jsonData);


			quickViewTable.setModel(quickModel);
		},

Thank you in advance.

maheshpalavalli
Active Contributor

Merge duplicates should work fine. So your issue is that with merge duplicates, it is not merging correctly and with grouping it merges correclty right?

BR,

Mahesh

0 Kudos

@maheshkumar.palavalli That is correct.

Accepted Solutions (0)

Answers (2)

Answers (2)

oliver_dammann1
Explorer

Your date is visualised via Title within ObjectIdentifier. The standard method used by mergeDuplicates is getText. This functions well with Text objects. But with ObjectIdentifier it could lead to wrong results if the content is stored in Title and not in Text. In your case you just have to add mergeFunctionName="getTitle" to your Column definition.

<Column id="hRe1ason" mergeDuplicates="true" mergeFunctionName="getTitle">

Long time after the question but may be useful for someone stumbling across it.

Try removing any growing properties from the Table. Something about this seems to interfere with the binding on any properties of the particular control in the cells aggregation.

When the rendering occurs, at the point of the merge duplicates the property (for example the text property of a Text control that is bound to a model) is not recognised and thinks every field is blank (and hence duplicate) so then merges everything.

Removing growing fixed it for me, and means you can remove the grouping on the sort if you don't want the headers.

EDIT: Continued looking at this further and you can have growing on provided you utilise the Custom Data addition to the control you are trying to merge.

Columns:

<columns>
   <Column width="15%" mergeDuplicates="true" mergeFunctionName="data#mergeKey">
      <header>
         <Text text="{i18n>PO}"/>
      </header>
   </Column>
   <Column width="7%" mergeDuplicates="true" mergeFunctionName="data#mergeKey">
      <header>
         <Text text="{i18n>CUSTPOITEM}"/>
      </header>
   </Column>
</columns>

ColumnListItems/Cells:

<items>
    <ColumnListItem>
	<cells>
           <Link text="{customerPO}" 
	         href="{ parts:['reqDate_date', 'material', 'customerPO', 'customerPOItem', 'site_code', 'customer_code'], formatter: '.getLinkURL'}">
		<customData>
        	    <core:CustomData key="mergeKey" value="{customerPO} + {reqDate_date}"/>
		</customData>
	   </Link>
	   <Text text="{customerPOItem}">
		<customData>
		    <core:CustomData key="mergeKey" value="{customerPO} + {customerPOItem} + {reqDate_date}"/>
		</customData>
	    </Text>
        </cells>
    </ColumnListItem>
</items>

The above two segments should work whilst growing is still on. If the Custom Data value property is only bound to one model element it is not recognised when growing is on. However if you concatenate an empty string onto the binding it is then recognised. The same effect is seen when you have multiple model elements bound to the value property (as above) the binding appears to start working again.

So this works:

 <core:CustomData key="mergeKey" value="{customerPO} + ''"/>

This doesn't:

 <core:CustomData key="mergeKey" value="{customerPO}"/>

I'm not sure why yet...

rb
Active Participant
0 Kudos

Thank you 🙂