cancel
Showing results for 
Search instead for 
Did you mean: 

Multi input Column filtering in Sap.ui.table is not working

0 Kudos

Hello Experts,

I am trying to implement sap.ui.table.column multi input Filtering in sap.ui.table . I am able to successfully create filters but it's not working. Please check below code which I implemented to create filters for multiple columns.

I have applied two input in first column separated by comma

Again applied two input in fourth column.

Xml view

<Table id="idParentTable" rows="{DetailData>/ProductCollection}" selectionMode="MultiToggle" visibleRowCount="10" visibleRowCountMode="Fixed" enableCellFilter="true" filter="filterCols" enableSelectAll="true" alternateRowColors="true">

<columns>

<Column id="idWBS1ID" filterProperty="Name" width="10rem" filterType="sap.ui.model.type.String"> <m:Label text="{i18n>WBS1ID}"/> <template> <m:Text text="{DetailData>Name}" wrapping="false"/> </template> </Column>

<Column width="10rem" filterProperty="Quantity" filterType="sap.ui.model.type.Integer"> <m:Label text="{i18n>WBS4_1_Element_ID}"/> <template> <m:Text text="{DetailData>Quantity}" wrapping="false"/> </template> </Column>

Controller


filterCols: function(oEvent) {

var that = this; oEvent.getParameter("column").setFiltered(true);

this.filterFormation();

},

filterFormation: function() {

var that = this;

that._oLFilter;

this.filteredColumn = [];

var oColumns = this.byId("idParentTable").getColumns();

oColumns.forEach(function(column) {

if (column.getFiltered()) {

var filterValue = column.getAggregation("menu").getAggregation("items")[0].getProperty("value");

filterValue.split(",").forEach(function(value) {

that.filteredColumn.push(new sap.ui.model.Filter(column.getProperty("filterProperty"), sap.ui.model.FilterOperator.Contains, value)); }) } });

this.aColArray = [];

this.previous = null;

this.aMainFilter = [];

this.bFlag = true;

that.filteredColumn.forEach(function(value) {

if (value.sPath === that.previous || that.previous === null) {

that.previous = value.sPath;

that.aColArray.push(value);

} else {

that.bFlag = false;

var aOrFilter = that.globalFilterFormation(that.aColArray);

that.aMainFilter.push(aOrFilter);

that.aColArray = [];

that.aColArray.push(value);

that.previous = value.sPath; }

})

if (this.bFlag = true) {

var aOrFilter = this.globalFilterFormation(this.aColArray);

that.aMainFilter.push(aOrFilter);

}

var goFil = new Filter(that.aMainFilter, true); //goFil Value is highlighted in below screenshot

this.byId("idParentTable").getBinding("rows").filter(goFil, "Application");

},

globalFilterFormation: function(aFilter) {

var oLFilter = new sap.ui.model.Filter(

{ filters: aFilter, and: false }

);

return oLFilter;

},

Accepted Solutions (0)

Answers (1)

Answers (1)

ThorstenHoefer
Active Contributor
0 Kudos

Hi,

Have you tried to bind the model to the table, and set only the Filter Property to the columns, whithout the table event filterCols?

The table itself should take care about the default filter function.

Please check following example:

https://sapui5.hana.ondemand.com/#/entity/sap.ui.table.Table/sample/sap.ui.table.sample.OData