Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » Filtering(Custom filtering using own DataProvider)
Filtering [message #1802321] Wed, 06 February 2019 12:16 Go to next message
Hallvard Traetteberg is currently offline Hallvard TraettebergFriend
Messages: 671
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 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2691
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.
Re: Filtering [message #1802335 is a reply to message #1802322] Wed, 06 February 2019 16:11 Go to previous message
Hallvard Traetteberg is currently offline Hallvard TraettebergFriend
Messages: 671
Registered: July 2009
Location: Trondheim, Norway
Senior Member
Thank you for your quick answer. I'm now able to use a different display converter, so I can validate the syntax of the expression. I use $ to support more complex expressions e.g. with &&. The underlying tablesaw Table class already has support for filtering, so that may be just as easy as using Nattable's classes. I just need to implement a custom IFilterStrategy, that uses tablesaw's filtering and asks Nattable to refresh.
Previous Topic:NatTable version 1.1.0 and Glazelist version 1.8.0 compatibility
Next Topic:NatTableContentTooltip constructor for testing
Goto Forum:
  


Current Time: Mon Jun 17 17:47:23 GMT 2019

Powered by FUDForum. Page generated in 0.02236 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top