How to apply a filter in Table and Report controls


Asley Cruz
Hi David, I found this function to filter a table. It works but the table in AB2 needs to be refreshed to take effect.
The table only takes effect when I do click in any other part of the project.

https://www.w3schools.com/howto/tryit.asp?filename=tryhow_js_filter_table

If you know to refresh the table, please, let me know. Many thanks David :)
AsleyCruz.com

Graphic & Web Designer


My app: AC Biblia

My game: AC Trivlia


decsoft

Hola Asley,

You no need to filter the table itself (the HTML markup), but the Table's "data" property. Whatever change you do into the "data" propery is automatically reflected in the table (HTML markup).



decsoft

Hello Asley,

Maybe a bit of code can clarify the things here. Based in the "Table" sample app, go to the "view1" Show event, and, replace the Javascript code that you can see by the below one:

Originally we set the Array into the "table1.data" property, but, to filter the contents, we save a copy of the original "table1.data" in another variable, in this case "app.store.tableOriginalData". Now place a Text Input control in the "view1", below the Table, and, place the below code in his "KeyUp" event:

That's all. Run the app and type something in the new Text Input control: you must see that only the records who his name contains the query (the Input Text value) is shown in the table and not other records. It's more or less easy to expand the search to other fields, etc. Please, go ahead if you have some further questions!



Asley Cruz
Hi David, many thanks for the code. It works like a charm :P
Have a nice sunday
AsleyCruz.com

Graphic & Web Designer


My app: AC Biblia

My game: AC Trivlia


decsoft
You're welcome, Asley! :-)

Everybody can read the DecSoft support forum for learning purposes, however only DecSoft customers can post new threads. Purchase one or more licenses of some DecSoft products in order to give this and other benefits.

This website uses some useful cookies to store your preferences.

I agree. Hide this note. Give me more information.