ADF: af:table filter modifications using a custom Query Listener
In one of our last projects we had the requirement to allow the user to filter tables using the table filter feature. By default you can filter String fields starting with the word that the user provides, but our customer needed to find the rows that contained the criteria.
This is an easy task that can be accomplished by creating a custom Query Listener method.
As by default the filter works with “Starts with” condition you will see that filtering by “tra” will give no result although departments like Administration exists.
In this example we will use Departments table in HR schema.
When we drag and drop to create a table and we set it to be filterable, we can see that a query listener has been created by default.
As we need to modify the filter values we need to create ouor own query listener.
The idea of this method is to get every value, and if it is String we have to change the original value and concatenate ‘%’ before and after the value.
After that we need to call the default query listener that we can get from queryListener property in the table component.
If we end here, the user would see the new filter with % symbol, so we are going to remove it and leave it as the user type it.
This is the helper method we use to call the default query listener.
The last step is to set our new method as the table’s query listener.
If we run the application we can see that if we filter by “tra”, we can now see some records.
6 Comments
Unknown
November 12, 2018
Hi,
is there any possiblity to set programmatically value to filterModel (Table field)?? i want to customize ADF table filter.
juan_zero
November 12, 2018
I've tried this solution and is good, but when you remove the "%" character using a table with scroll policy "page" and go to the next page it gives the error: "Definition vc_temp_1 of type Variable is not found in ViewDef…". Any idea of what could be happening in this case?
Unknown
November 12, 2018
Please share the code.
Unknown
November 12, 2018
Excelente!
Shrikant1988
November 12, 2018
can we achive same thing in jdeveloper 11.1.1.7,
Gaurang
September 24, 2020
Thanks for sharing. Extremely helpful.