-
Julia4 years ago #18695
Hello everybody,
is there a way to add filter and sort functions to the table columns?
Thanks!
JuliaMathieu RollHas successfully completed the online course IntroductionHas successfully completed the online course Intermediate (200)Has successfully completed the online course Advanced (300)Has successfully completed the online course Basics (100)4 years ago #18898::Hello,
please find attached an example application (ShoppingList).
In the example i’m using the UI5 Model Filter.
Chris BouveretHas successfully completed the online course IntroductionHas successfully completed the online course Intermediate (200)Has successfully completed the online course Advanced (300)Has successfully completed the online course Basics (100)Has successfully completed the online course Advanced (320)Has successfully completed the Intermediate CertificationHas successfully completed the Advanced Certification4 years ago #18696Julia4 years ago #18701::Hi Chris,
thanks for the doc. I’ve seen this before. But I’m stuck with using this in the app.
That type of table do I have to use? sap.ui.table.Table? sap.m.Table? Or another?
I’ve seen with ui-Table there are options like enableCellFilter. Is this the enabling for this functions? (Although I’m hanging with getting my data in the table at the moment).
How to use them?
Thanks!
Juliajonas.rauschHas successfully completed the online course IntroductionHas successfully completed the online course Intermediate (200)Has successfully completed the online course Advanced (300)4 years ago #18706::Hi Julia,
Since Ui5 Filters work on the Data Model of the corresponding Table, you can Filter any Table you want.
I´d say the easiest Example would be the sap.m.Table.
Unfortunately, the Filter Function needs to be added via script, there is no Simplifier Function for that yet.
The First thing you need to do:
create a new Filter: new sap.ui.model.Filter([key in model you want to filter(column)], [Filter function], [value you want to filter by])
Second: Apply the Filter to the Model:
[your model reference].filter([The new Filter]);
I hope this helps.
Julia4 years ago #18719::Hi Jonas,
since I am still very new to the topic, could you give me an exact example of how to insert the filter?
More precisely, I need several filters, since I have different columns.
One is a filter that allows me to select all the possibilities that are in this column (texts/places) (with multiple selection).
And a filter with which I can filter in a column with date-time data according to a time period in the column.
I also have columns with checkboxes, for which a filter function would also be good, and numerical values (costs).I would like to equip all columns with filters? Is there any documentation on how to use and install these filters? Or do you / do you have examples for me?
Thanks in advance for your help!
Juliajonas.rauschHas successfully completed the online course IntroductionHas successfully completed the online course Intermediate (200)Has successfully completed the online course Advanced (300)4 years ago #18744::Unfortunately, I dont have any examples at hand, but you can take a look at the table Filtering example of the UI5 Documentation:
https://sapui5.hana.ondemand.com/#/entity/sap.ui.table.Table/sample/sap.ui.table.sample.Filtering
The Filter Part works for all model bound data, like tables and lists.
The ui.table.table already has inputs for the filter values, but you can easily add the inputs to your app
You can add Multiple Filters at once using a Filter Array:
https://sapui5.hana.ondemand.com/#/api/sap.ui.model.Filter
I hope this helps a bit, but dont worry if you cant get it to work on your first try, filters are on of the more complex things you can do with UI5
Julia4 years ago #19003::Hello!
Thank you very much! It works now! 🙂
Two more question has arisen from this while implementing the filters for one column.
In the selection list for the filter is now for every row value in the table on selection. So I have the same selection value ten times and more, for example if I want to filter for “notebook”, I have this selection for every notebook (over 10 times), and not just one selection for notebook.
Can I somehow collapse the values?And, in my list I have check boxes. How can I filter check boxes? Or do you have another idea for handling true/false values in a table and SQLite database?
Thank you very much!
Juliajonas.rauschHas successfully completed the online course IntroductionHas successfully completed the online course Intermediate (200)Has successfully completed the online course Advanced (300)4 years ago #19259::Hi Julia,
Im not entirely certain what you mean with your first question. Could you maybe elaborate a bit further?
In Regards to the second Question, Boolean values in sqlite are typically handled via Int values where 0=false and anything else means true.
So in the model, you´ll have int representations of your boolean staats.
The Checkbox´s selected property can be bound to that via an expression binding to these values.
You can than simply filter for 0 and 1 in your model like you would with e.g. names
hope this helps
You must be logged in to reply to this topic.