cancel
Showing results for 
Search instead for 
Did you mean: 

custom filter for all components sap.ui.table.table

0 Kudos
1,806

Hi, guys!

I need to create a general event for all sap.ui.table.table components where when a column is filtered I can retrieve the column name and the entered value but can't.

What would be the best way to do this?

I'm trying like this:

sap.ui.table.Table.prototype.constructor.prototype.attachFilter = function() {
    console.log(this.getBinding().aFilters);
};

Thank you very much in advance.

Accepted Solutions (1)

Accepted Solutions (1)

Hi Carlos,

Please reqister attachFilter event to the table as below,

oTable.attachFilter(function(oEvent){ var oSource= oEvent.getSource(); });

Once the event registered, it will trigger whenever we tries to filter a table. Please find the attached screenshot where you can see entered value and Column details. filters.png

Thanks,

Kumar Karanam

Answers (1)

Answers (1)

smarchesini
Active Contributor

Hi cgomes_enginnering ,

I think is easier in with standard event.
In the xml (if you have that) add the event (filter="FILTEREVENT"😞

<Table
				id="table"
				selectionMode="MultiToggle"
				rows="{/ProductCollection}"
				visibleRowCount="7"
				enableCellFilter="{ui>/cellFilterOn}"
				filter="FILTEREVENT" 
				ariaLabelledBy="title">


And in the controller get the name of column and value of filter:

FILTEREVENT: function(oEvent) {

                        var sValue = oEvent.getParameter("value") //value
			var sColumn = oEvent.getParameter("column").getId();

			oEvent.preventDefault();
			
		},