cancel
Showing results for 
Search instead for 
Did you mean: 

How to enable search for each column on sap.m.table ?

0 Kudos

Hi Experts,

I am trying to create an individual search for each column in my sap.m.table. I had tried the same thing in the grid table by enable cell filter however the grid table doesn't satisfy my need to certain level and also some functions. So can anyone please guide me how to enable each column search in the m library table.

Regards

Raman Nanda

Accepted Solutions (0)

Answers (1)

Answers (1)

priteshpatel65
Active Participant
0 Kudos
try this. may be fulfil your requirement.
sap.ui.define([ 
"sap/ui/core/mvc/Controller", 
'sap/ui/model/json/JSONModel',
],
function (Controller, JSONModel) { 
"use strict";
return Controller.extend("project1.controller.View1", { 
onInit: function () { 
var oTable = this.getView().byId("idProductsTable"); 
var that=this; 
oTable.addEventDelegate({ 
onAfterRendering: function() { 
var oHeader = this.$().find('.sapMListTblHeaderCell');  
for (var i = 0; i < oHeader.length; i++) { 
var oID = oHeader[i].id; that.onClick(oID); 
} 
} }, oTable);
}, 
onClick: function(oID) { 
var that = this;
 $('#' + oID).click(function(oEvent) {  
var oTarget = oEvent.currentTarget; 
 var oLabelText = oTarget.childNodes[0].textContent; 
 var oIndex = oTarget.id.slice(-1);
 var oView = that.getView();
 var oTable = oView.byId("idProductsTable");
 var oResponsivePopover = that.getView().byId("helloResponsivePopover");
 oResponsivePopover.openBy(oTarget); 
}); 
} 
}); 
});


<mvc:View controllerName="project1.controller.View1" xmlns:mvc="sap.ui.core.mvc" xmlns:core="sap.ui.core" xmlns="sap.m"> 
<Page id="page" title="{i18n>title}">
 <Table id="idProductsTable" >
 <columns> <Column>
 <Text text="Product" />
 </Column> <Column> 
<Text text="Supplier" />
 </Column> <Column> 
<Text text="Dimensions" />
 </Column> <Column> 
<Text text="Weight" /> 
</Column> <Column>
<Text text="Price" /> 
</Column> </columns>
 <items> 
<ColumnListItem > 
<cells>
 <Text text="{}" /> 
<Text text="{}" /> 
<Text text="{}" /> 
<Text text="{}" />
 <Text text="{}" />
 <Text text="{}" /> 
</cells> 
</ColumnListItem>
 </items>
 </Table>
 <ResponsivePopover id="helloResponsivePopover" placement= "cells" afterOpen= "onOpen"> 
<content>
 <List>
 <items>
 <CustomListItem type="Active" press="onAscending">
 <Label text="Sort Ascending" /> </CustomListItem> 
<CustomListItem type="Active" press="onDescending">
 <Label text="Sort Descending" /> 
</CustomListItem>
 </items> </List> 
</content> 
</ResponsivePopover>
 </Page> 
</mvc:View>