Filtering [message #1802321] |
Wed, 06 February 2019 12:16 |
Hallvard Traetteberg Messages: 673 Registered: July 2009 Location: Trondheim, Norway |
Senior Member |
|
|
I'm using Nattable on top of Tablesaw (a Java library for data analysis), currently for a CSV editor, but I hope to make something more like a workbench. I'm in general very happy with its design!
Now, I want to implement filtering, and have succeeded in adding the filter row, but not support correct editing and filtering.
First, I want to support filter expressions, so instead of inputting a simple value, you should be able to type something like $>10. However, the DisplayConverter that's used is the same as the one used for the actual data, so $>10 is rejected, since it's not a number. How can I attach a DisplayConverter that's specific for the filter row.
Second, I wonder how to implement the filtering itself. I can filter the underlying source (a Tablesaw table), but wonder if Nattable supports filtering only the view, without requiring med to use glazed lists as the data source.
|
|
|
Re: Filtering [message #1802322 is a reply to message #1802321] |
Wed, 06 February 2019 13:14 |
Dirk Fauth Messages: 2902 Registered: July 2012 |
Senior Member |
|
|
Not sure why you need the $ sign in your expression, because such expressions should be already working. You can have a look at the _6031_GlazedListsFilterExample to get an idea.
But that was not your question. You can register a converter for the filter row by using the corresponding labels and config attributes. For example:
configRegistry.registerConfigAttribute(
FilterRowConfigAttributes.FILTER_DISPLAY_CONVERTER,
new DefaultIntegerDisplayConverter(),
DisplayMode.NORMAL,
FilterRowDataLayer.FILTER_ROW_COLUMN_LABEL_PREFIX
+ DataModelConstants.HOUSENUMBER_COLUMN_POSITION);
There we also support regular expressions, at least in combination with GlazedLists.
With regards to the other question, well actually I see the GlazedLists usage as part of the view and not the data source. But anyhow, if you have some other non-list based data source, it gets complicated. We have a AbstractFilterListDataProvider where you can place your filter logic, but that also works on a list. If you have a list, I'll suggest to wrap the data source list in a FilterList. If you have some other data source, you need to find yourself a way how to filter what should be shown in the NatTable. You could try to make use of the RowHideShowLayer or RowIdHideShowLayer with some custom IFilterStrategy. But I am not sure what effort that would be.
|
|
|
|
Powered by
FUDForum. Page generated in 0.03471 seconds