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! :-)

Todo el mundo puede leer el foro de soporte de DecSoft para aprender del mismo, sin embargo, sólo los clientes de DecSoft pueden abrir nuevos hilos. Compre una o más licencias de productos de DecSoft y obtendrá este y otros beneficios.

Este sitio utiliza "cookies" útiles para almacenar sus preferencias.

Bien. Ocultar esta nota. Obtener más información.