Filter Lists in Columns [message #1835859] |
Tue, 15 December 2020 10:46 |
Jerome Holbein Messages: 15 Registered: June 2020 |
Junior Member |
|
|
In our application we have multiple tables, where certain AbstractStringColumns show comma-separated lists of strings. For example:
"Anna, Bea, Christoff"
"Anne, Detlev, Erika"
...
In such cases I would want to change the functionality of the column filter to work by List-Element instead of Column-Element. Currently the filter would create a list of column elements which would create separate entries "Anna, Bea" and "Anna, Christoff". Instead I would want to have a filter list that contains "Anna", "Bea" and "Christoff" exactly once and separate. Sure, I could use the free text field, but to get an overview over the entries such an overwritten filter would still be useful and more elegant. Is that possible?
On a related note, what is the best way to display a Collection of Objects in a column anyway? We've been using AbstractStringColumns, since it allows us to use HtmlEnabled and TextWrap, but maybe there's a proposed better way, that I just don't know about. Actually being able to see and interact with the different list-elements would be great and having to double the whole row, just to separate the values of one column feels like overkill.
Cheers,
Jerome
|
|
|
|
Re: Filter Lists in Columns [message #1836766 is a reply to message #1836693] |
Wed, 13 January 2021 13:49 |
|
Hi Jerome
No, this is not possible out-of-the-box. The current filter implementation treats cell contents as text, which works well for most use cases.
I see two possibilities:
(A)
Use search forms to let the user define complex filters before the data is loaded, e.g. by adding a WHERE condition to an SQL query. This has the additional benefit of saving resources, especially when handling large data sets. The downside is that it requires more interaction from the user.
(B)
Define your own column type, e.g. ListColumn. You could then override createTableHeaderMenu() and replace or extend the entire header menu for that column. By overriding TableHeaderMenu._renderFilterTable() you can customize the filter table.
Another approach would be to use a custom ColumnUserFilter. As you may have noticed, the list entries for DateColumns only consist of the year, not of each individual date value. You could try to extend the ColumnUserFilter such that it extracts the available values from your data structure.
This second approach will take some time and effort, but may be worth it if you have many of those columns and your users do lots of that kind of filtering.
Collections of objects in a single column are non-trivial and there is no out-of-the-box solution for that. I think most developers use some sort of HTML content. This works reasonably well for display purposes, but filtering, sorting, editing and exporting data poses some challenges. It is usually recommended to find other solutions, or disable the header menu for such columns.
Regards,
Beat
|
|
|
|
Re: Filter Lists in Columns [message #1836851 is a reply to message #1836805] |
Fri, 15 January 2021 15:40 |
|
There is no full "sandbox" example yet, I'm afraid. But there are already a few specialized columns in Scout that you can refer to, such as DateColumn (JsonDateColumn, DateColumn.js), BooleanColumn, IconColumn.
The main difference between Scout 9 and Scout 10 was the migration of the JavaScript code to ES6. The basic Scout concepts are still mostly the same.
Regards,
Beat
|
|
|
|
Powered by
FUDForum. Page generated in 0.15067 seconds