Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » Quick Search feature in the Excel like filters(Implementing a quick search textbox feature to filter the combobox filter list)
Quick Search feature in the Excel like filters [message #1709021] Wed, 23 September 2015 11:16 Go to next message
Cristi Andrei is currently offline Cristi AndreiFriend
Messages: 21
Registered: August 2015
Junior Member
I'm trying to implement a quick search feature in the excel like filters for my nattable. Something like the Excel filters have (See upload).

Can I somehow combine the text filter (FilterRowHeaderComposite) with the combobox filter (ComboBoxFilterRowHeaderComposite) as to have a cell where I can type some text and filter the combobox filter list?

Is there any simple way to do this without using the Painter to create a new UI component that runs like the excel like filter only with the added textbox to filter the comboboxes?

If this doesn't work, can I somehow have two header rows, one for Comboboxes and one for Text filter?

Any ideas?

[Updated on: Wed, 23 September 2015 11:17]

Report message to a moderator

Re: Quick Search feature in the Excel like filters [message #1709033 is a reply to message #1709021] Wed, 23 September 2015 12:36 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2809
Registered: July 2012
Senior Member
Haven't looked into this, but I suppose you need to use/configure the combobox to support free text and tell the content that this means to filter the combobox content.
Re: Quick Search feature in the Excel like filters [message #1709104 is a reply to message #1709033] Thu, 24 September 2015 06:14 Go to previous messageGo to next message
Cristi Andrei is currently offline Cristi AndreiFriend
Messages: 21
Registered: August 2015
Junior Member
How exactly should I configure it?

I presume you're talking about the ComboBoxFilterRowHeaderComposite class, since I see there is where the combobox is created.

Only that the class, besides the get and set methods, has a doCommand method which does the actual filtering after i check a box, and the rest of the UI component is done in its constructors. Normally I'd extend the class and overwrite the method responsible for a certain behaviour, to do something, only slightly different. However, here, I can't exactly see how I'd do that since it's not possible to overwrite class constructors.

A method to filter by text the combobox filters I could do, I'd just have to add a textbox (or make the cell editable), transmit the parameter from the textbox and then search by regular expression in the filterList and create a new filterList to load in the ComboBoxFilterRowHeaderComposite. But I don't know how I could correctly integrate this with the current NatTable.

Any advice? I apologize, but I'm not exactly proficient with NatTable or Eclipse plugins, I'm just trying to learn.

[Updated on: Thu, 24 September 2015 06:53]

Report message to a moderator

Re: Quick Search feature in the Excel like filters [message #1709109 is a reply to message #1709104] Thu, 24 September 2015 07:06 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2809
Registered: July 2012
Senior Member
Well, it is not that easily explained. You have to dig through the code. Here are some hints that might help:



  1. The content in the combo box is provided via IComboBoxDataProvider. By default the GlazedListsFilterRowComboBoxDataProvider is used that checks the data in the corresponding column to determine the available values. You need to create a custom one that supports filtering of the content and you can set that at creation time (constructor).
  2. By default the FilterRowComboBoxCellEditor is used as the editor for the excel like filtering. It uses the FilterNatCombo, which is a NatCombo, which is our NatTable internal combo box control. Free editing is supported by that control, but disabled at creation time in FilterRowComboBoxCellEditor#createEditorControl() (style bit READ_ONLY). So in theory you need to create a custom version of FilterRowComboBoxCellEditor that supports free editing and registers a listener for editing the text control to trigger filtering the combobox content.
  3. By default the ComboBoxFilterRowConfiguration is activated at creation time. This one sets a FilterRowComboBoxCellEditor as the editor to use. You need to create the ComboBoxFilterRowHeaderComposite with constructor parameter useDefaultConfiguration == false and specify a custom configuration. In your custom configuration you need to specify your custom editor.


I hope these informations help you implementing such a filter feature. Of course we would also like to see such a feature contributed to NatTable for other users. Wink

[Updated on: Thu, 24 September 2015 07:07]

Report message to a moderator

Re: Quick Search feature in the Excel like filters [message #1709786 is a reply to message #1709109] Thu, 01 October 2015 06:49 Go to previous messageGo to next message
Cristi Andrei is currently offline Cristi AndreiFriend
Messages: 21
Registered: August 2015
Junior Member
Ok, I managed to do something like a quick search like this: The cell where you press for the combobox context menu is now editable. A listener is there and collects a string which then passes it to an algorithm as a regular expression to search for names in the filter list so that the only visible combobox filters are the ones whose name contains the word you write in the header cell. Kinda buggy for the moment but it works.

Now I have a question: Normally in order to refresh the combobox filters I have to press Enter and then get the context menu out again in order to see the changed combobox list. How can I do that on the fly, as the combobox filter list to dynamically change depending on what I type in the cell? I think there is a command that does the refresh when I click somewhere else on the table or I press the Enter key. Could you point me out to that command or mechanism that does the context menu refresh?

Also, say I want to have this feature only on my first column and the rest to be usual non editable combobox filters. How can I set just one cell/column to have this filter implementation?

[Updated on: Thu, 01 October 2015 11:55]

Report message to a moderator

Re: Quick Search feature in the Excel like filters [message #1709820 is a reply to message #1709786] Thu, 01 October 2015 11:39 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2809
Registered: July 2012
Senior Member
Have a look at the NatTable Examples Application -> Tutorial Examples -> GlazedLists -> Filter -> GlazedListsFilterExample

There the first column supports immediate filtering on key press.

In short, if only the first column should support something, then only register the configuration for that column.
And if you want to do something on key press, register a key listener that executes something on key press.
Re: Quick Search feature in the Excel like filters [message #1709827 is a reply to message #1709820] Thu, 01 October 2015 11:59 Go to previous messageGo to next message
Cristi Andrei is currently offline Cristi AndreiFriend
Messages: 21
Registered: August 2015
Junior Member
Regarding the first problem, to dynamically change the combobox filter dropdown menu, I found a solution in the fillCombo() method from ComboBoxCellEditor, in the combo.setItems() method (where I can add my filtered list of filters).

However I simply cannot find a method that removes Items instead, or that empties the said list. I can only add indefinitely Items to my filter list context menu.

Is there a method to remove items? Can I implement one? If so how exactly could I?

Is there a method to empty my filter list as in a combo.disposeItems() ? Can implement one?

I already have a listener that does just that, only that I don't want to applyFilter() or filter the table at all, when I press the key. I want to filter the combobox filter list dropdown menu (that you get when you click on the arrow image to check boxes of what you want to filter) so that instead of getting all comboboxes to check I only see only the ones that contain the string I typed in the cell.
Re: Quick Search feature in the Excel like filters [message #1709860 is a reply to message #1709827] Thu, 01 October 2015 14:15 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2809
Registered: July 2012
Senior Member
IIRC the dataprovider for the combobox is itself based on a FilterList. The content should be dynamically calculated to react on data model changes. So I assume you need to operate on the list to achieve what you want.

But how should I suggest what you should do without knowing what you did? I guess you need to override the default implementation or work on the FilterList of the dataprovider by applying/removing a filter.
Re: Quick Search feature in the Excel like filters [message #1709929 is a reply to message #1709860] Fri, 02 October 2015 05:45 Go to previous messageGo to next message
Cristi Andrei is currently offline Cristi AndreiFriend
Messages: 21
Registered: August 2015
Junior Member
Let me do a quick recap of what I did

First of all I have a non editable nattable, to which I want to add a filter header layer with the ComboBox Filter, except that when I type into the header row cells, the ComboBox filters in the dropdown menu to automatically filter depending on what I type. Say initially I have 10 ComboBoxes that I can select/check in the dropdown menu, 5 of them start with "A". I write "A" and the dropdown menu now shows only the five comboboxes that start with "A". I delete "A" and again all 10 comboboxes show up again in the dropdown menu. No filtering in the actual table, only in the dropdown menu that shows Comboboxes to select/check.

Now for what I've done:

1) created a ComboBoxFilterRowHeaderComposite with constructor parameter useDefaultConfiguration == false and specified a custom configuration. Created my very own custom ComboBoxFilterRowConfiguration1.

2) created a customFilterRowComboBoxCellEditor1 (from which I removed the SWT.READ_ONLY as to make it editable) and also added a listener in the createEditorControl method which notices if I write something in the header row cell and collects what I write in a string variable.

3) created a custom ComboBoxCellEditor1 which is identical to the original ComboBoxCellEditor but I changed canonicalValues and the fillcombo method to protected. Also made my customFilterRowComboBoxCellEditor1 extend this class.

4) overwrited the fillCombo method from ComboBoxCellEditor1 to add to the dropdown menu the elements that correspond to the word I write in the editable cell:

	@Override
	public void fillCombo() {
		List<String> displayValues = new ArrayList<String>();

		List<?> values;
		if (this.comboBoxDataProvider != null) {
			values = this.comboBoxDataProvider.getValues(getColumnIndex(),
					getRowIndex());
		} else {
			values = this.canonicalValues;
		}

		for (Object canonicalValue : values) {
			if (canonicalValue.toString().contains(textValue)) // textValue is the string collected in the listener
				displayValues.add((String) this.displayConverter
						.canonicalToDisplayValue(this.layerCell,
								this.configRegistry, canonicalValue));
		}

		this.combo.setItems(displayValues.toArray(ArrayUtil.STRING_TYPE_ARRAY));
	}


I think this could have been done directly in the listener with combo.setItems(filteredListOfComboBoxFilters), but I had hoped using fillCombo would replace the dropdown menu content with the new one, instead it just adds to it indefinitely.

So here comes my problem. How do I remove Items from the dropdown menu. I get it, with setItems() method I can add to it but I can find no method that removes Items from it or that empties the dropdown menu, as to only introduce the list I want to see.

I need something like combo.removeItems(List), combo.empty(), combo.disposeItems() to get rid of the Items that were originally in the dropdown menu, at creation.

[Updated on: Fri, 02 October 2015 06:15]

Report message to a moderator

Re: Quick Search feature in the Excel like filters [message #1709938 is a reply to message #1709929] Fri, 02 October 2015 07:25 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2809
Registered: July 2012
Senior Member
No, what you need is the possibility to specify a filter on the NatCombo. Looking in the code, the NatCombo dropdown is internally implemented as a Table.

So with the current code base it seems to be not possible to implement your requirement with NatTable defaults. You could try to create a custom NatCombo based on the existing, implement the dropdown table as a TableViewer and provide the possibility to specify a ViewerFilter on that.

I can't remember why I have chosen a Table instead of a TableViewer back in the days. Either it was the handling of checkboxes or the size calculation that didn't work as I suspected. But maybe you have more luck on this.

Of course this would be nice to have in the NatTable codebase itself. Contributions are welcome!
Re: Quick Search feature in the Excel like filters [message #1709971 is a reply to message #1709938] Fri, 02 October 2015 10:05 Go to previous messageGo to next message
Cristi Andrei is currently offline Cristi AndreiFriend
Messages: 21
Registered: August 2015
Junior Member
I managed it, by creating a custom FilterNatCombo and implementing a removeAllItems()

public void removeAllItems() {
		dropdownTable.removeAll();	
	}


Now I can modify the dropdown on the fly as I type. Also gonna implement a removeItem() method to fine tune the feature.
Re: Quick Search feature in the Excel like filters [message #1710243 is a reply to message #1709971] Mon, 05 October 2015 13:41 Go to previous messageGo to next message
Cristi Andrei is currently offline Cristi AndreiFriend
Messages: 21
Registered: August 2015
Junior Member
So, the Quick-Search feature works pretty good up till now, though it has a few quirks I'm trying to fix.

One of which is the editable cell. As I mentioned before I made the header row cells editable by removing the READ.ONLY bit from the style variable. Unfortunately I can't make the text I write in it to stick like with the normal Filter (see example GlazedListsFilterExample) where I type the word, move the cursor to another cell and the word sticks to the header cell.

The implementation of FilterRowHeaderComposite and DefaultGlazedListsFilterStrategy seem to be fairly different as I have not noticed any CellEditor or Configuration like when I was meddling with the ComboBoxFilters.

Is there anywhere in my CellEditor where I could specify something to make the test I write in the editable cell stick to it? Like when writing in a normal nattable cell?
Re: Quick Search feature in the Excel like filters [message #1710247 is a reply to message #1710243] Mon, 05 October 2015 13:54 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2809
Registered: July 2012
Senior Member
You will need some mechanism that stores such an information separately from the filter dataprovider. Internally the selected items in the combobox are translated to the string that is translated as filter expression. This is transported via the text control, that contains some validator to show nothing in the usual case.
Re: Quick Search feature in the Excel like filters [message #1710341 is a reply to message #1710247] Tue, 06 October 2015 07:53 Go to previous messageGo to next message
Cristi Andrei is currently offline Cristi AndreiFriend
Messages: 21
Registered: August 2015
Junior Member
So, by removing the validator in the text control I can make the cell store the information I write in it? It's pretty annoying that whenever I leave the cell, the word I write to filter the ComboBoxes dissappears, and I have to press 'backspace' to get them all again.

Can you point me to any class or method of the text control as to narrow my code digging?
Re: Quick Search feature in the Excel like filters [message #1710351 is a reply to message #1710341] Tue, 06 October 2015 08:06 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2809
Registered: July 2012
Senior Member
The text control is part of NatCombo

The content should be set in FilterRowComboBoxCellEditor

I would need to investigate myself to remember what I did to achieve the current result.

Re: Quick Search feature in the Excel like filters [message #1710423 is a reply to message #1710351] Tue, 06 October 2015 14:59 Go to previous messageGo to next message
Cristi Andrei is currently offline Cristi AndreiFriend
Messages: 21
Registered: August 2015
Junior Member
Yeah, I found the text control in NatCombo. It's all rather strangely implemented, especially the multiple check. I suppose the method call that empties my cell is text.dispose() from the listener situated in createEditorControl().

Well commenting that line hasn't bore much fruit, it doesn't change anything, my text still dissapears and some other bugs appear, so I guess it's a bad idea. I'll get back to it later anyway.

Meanwhile is there any easy way to restrict my newly made feature to only the first n columns? (First 3 in my case)
Say I want the ComboBox with QuickSearch filter on my first 3 columns and the normal Combobox with uneditable cells on the rest.


Re: Quick Search feature in the Excel like filters [message #1710426 is a reply to message #1710423] Tue, 06 October 2015 15:03 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2809
Registered: July 2012
Senior Member
Simply register it only for the first three columns. Use the label FilterRowDataLayer.FILTER_ROW_COLUMN_LABEL_PREFIX + <column_position> for that as shown in various examples.
Re: Quick Search feature in the Excel like filters [message #1710431 is a reply to message #1710426] Tue, 06 October 2015 15:14 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2809
Registered: July 2012
Senior Member
Regarding the text control:

the problem is that the text control and the dropdown are linked internally. This is to show the selection for single selection in the text control. To keep that principle the multiselection is doing the same. For the filter the value is hidden somewhere, but I can't remember where I did this.

You might want to have a look at our EditorExamples in the Examples Application. There you see an example of the NatCombo that prints the selected items in the text field.
Re: Quick Search feature in the Excel like filters [message #1710690 is a reply to message #1710431] Thu, 08 October 2015 12:31 Go to previous messageGo to next message
Cristi Andrei is currently offline Cristi AndreiFriend
Messages: 21
Registered: August 2015
Junior Member
I did manage to make something out of it, regarding the text control.

1) in my custom FilterRowComboBoxCellEditor at createEditorControl, where the FilterNatCombo object is created, I sent through it's constructor the textValue that was collected from the listener.

2) I added a couple new constructors in FilterNatCombo and changed some constructors in NatCombo as to collect the textValue at creation

3) I added some code to the createTextControl method:

		if (textValue != null && !textValue.isEmpty())
			text.setText(textValue);


Which remembers the last word I typed in the editable cell and set's it when i open the dropdown.
Re: Quick Search feature in the Excel like filters [message #1711136 is a reply to message #1710690] Tue, 13 October 2015 11:43 Go to previous messageGo to next message
Cristi Andrei is currently offline Cristi AndreiFriend
Messages: 21
Registered: August 2015
Junior Member
Regarding the configuring filter options on columns I have been encountering some problems.

I tried two ways to create my Filter Row.

1) The first one is a Regular filter row and try to apply my custom Combobox on the first column, all rest remaining normal filters.

		DefaultGlazedListsFilterStrategy<FTLVariableEvolution> filterStrategy = new DefaultGlazedListsFilterStrategy<FTLVariableEvolution>(
				filterList, autoFilterMatcherEditor, columnPropertyAccessor,
				configRegistry);

		FilterRowHeaderComposite<FTLVariableEvolution> filterRowHeaderLayer = new FilterRowHeaderComposite<FTLVariableEvolution>(
				filterStrategy, columnHeaderLayerStack,
				columnHeaderDataProvider, configRegistry);

		FilterRowComboBoxDataProvider2<FTLVariableEvolution> comboBoxDataProvider = new FilterRowComboBoxDataProvider2<FTLVariableEvolution>(
				glazedListsEventLayer, sortedList, columnPropertyAccessor);

		FilterRowComboBoxCellEditor2 cellEditor = new FilterRowComboBoxCellEditor2(
				comboBoxDataProvider, 10);

		configRegistry.registerConfigAttribute(
				EditConfigAttributes.CELL_EDITOR, cellEditor,
				DisplayMode.NORMAL,
				FilterRowDataLayer.FILTER_ROW_COLUMN_LABEL_PREFIX + 0);


This causes my Custom ComboBox Filter to glitch out.

The other way I tried is creating a ComboBox Filter Row and specifying in the configuration on which columns I want to put each filter

ComboBoxFilterRowHeaderComposite<FTLVariableEvolution> filterRowHeaderLayer3 = new ComboBoxFilterRowHeaderComposite<FTLVariableEvolution>(
				filterList, origComboBoxDataProvider, columnPropertyAccessor,
				columnHeaderLayer, columnHeaderDataProvider, configRegistry,
				false);

		ComboBoxFilterRowConfiguration2 configuration = new ComboBoxFilterRowConfiguration2(
				comboBoxDataProvider);

		filterRowHeaderLayer3.addConfiguration(configuration);

		FilterRowComboBoxCellEditor comboBoxOrientationFilter = new FilterRowComboBoxCellEditor(
				origComboBoxDataProvider, 10);

		for (int i = 1; i <= 100; i++) {
            if(i<=2)
			configRegistry.registerConfigAttribute(
					EditConfigAttributes.CELL_EDITOR,
					comboBoxOrientationFilter, DisplayMode.NORMAL,
					FilterRowDataLayer.FILTER_ROW_COLUMN_LABEL_PREFIX + i);
			if(i>2)
			configRegistry.registerConfigAttribute(
					EditConfigAttributes.CELL_EDITOR,
					new FilterRowTextCellEditor(), DisplayMode.NORMAL,
					FilterRowDataLayer.FILTER_ROW_COLUMN_LABEL_PREFIX + i);
		}



In my custom Configuration I have only the registerConfig or the first column:

		configRegistry.registerConfigAttribute(
				EditConfigAttributes.CELL_EDITOR, this.cellEditor,
				DisplayMode.NORMAL,
				FilterRowDataLayer.FILTER_ROW_COLUMN_LABEL_PREFIX + 0);


This instead, makes for only my first 3 columns being ok and the regular filters glitching out.

How can I add a regular FilterRowLayer on the rest of the columns? I can't seem to mix ComboBox filters and Regular filters on the same FilterRow, whenever I try to add one the other stops working or glitches out.

What I want to achieve basically is:

Table:
(FilterRow) CustomCombo | NormalCombo | NormalCombo | NormalTextFilter | NormalTextFilter | ... | NormalTextFilter

[Updated on: Tue, 13 October 2015 11:49]

Report message to a moderator

Re: Quick Search feature in the Excel like filters [message #1711137 is a reply to message #1711136] Tue, 13 October 2015 12:01 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2809
Registered: July 2012
Senior Member
a) I don't know what you mean by "glitches out"

b) a combination of combo box filters and text filters doesn't work with the NatTable code base.

The reason for this is the transformation of the selected values to a filter. Using the normal text, simply the entered text is used as filter string, while using a combo box, the selected items are concatenated to a OR combination filter string.
So you would need to implement an IFilterStrategy that knows which editor is used to identify which mechanism to use for building the filter string.
Re: Quick Search feature in the Excel like filters [message #1711144 is a reply to message #1711137] Tue, 13 October 2015 12:45 Go to previous messageGo to next message
Cristi Andrei is currently offline Cristi AndreiFriend
Messages: 21
Registered: August 2015
Junior Member
"Glitch out" = either fails to work or makes my table disappear or crashes my application entirely -> that's how I meant it anyway

Sounds like a lot of trouble. How about removing any kind of filter from columns 3+? Right now when I try to only register the ComboBox Filter, the other columns get filled with a string that looks like an array (probably the multiselect from the NatCombo) and when I click on them, my whole table disappears.

Do I have to modify the NatCombo for this, as to organize the multiselect on only the first three columns?
Re: Quick Search feature in the Excel like filters [message #1711148 is a reply to message #1711144] Tue, 13 October 2015 13:05 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2809
Registered: July 2012
Senior Member
No, as said before you have to implement a custom IFilterStrategy because the ComboBoxGlazedListsFilterStrategy is doing the transformation and multiselect handling. Why should you modify the NatCombo if you don't want to use the NatCombo?
Re: Quick Search feature in the Excel like filters [message #1711394 is a reply to message #1711148] Thu, 15 October 2015 14:16 Go to previous messageGo to next message
Cristi Andrei is currently offline Cristi AndreiFriend
Messages: 21
Registered: August 2015
Junior Member
By any chance, does it have any performance issues when handling huge amounts of data (about 10000 rows and 50000 collumns) with the ComboBox RowFilter?

Normally, and with the normal filter, I noticed it works all right. But when I add the comboBox row filter, it takes a very long time (about 5 minutes) to render the table.
Re: Quick Search feature in the Excel like filters [message #1711396 is a reply to message #1711394] Thu, 15 October 2015 14:28 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2809
Registered: July 2012
Senior Member
Yes that might be, because to fill the comboboxes the whole table gets scanned. So technically using the combobox filterrow, the virtual nature in terms of only accessing what is visible is avoided. Similar to performing an autoresize.
Re: Quick Search feature in the Excel like filters [message #1711471 is a reply to message #1711396] Fri, 16 October 2015 11:00 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2809
Registered: July 2012
Senior Member
I looked into the implementation and think this can be corrected. I played around with a lazy loading mechanism, so the filter combo values are initialized and cached on request and not at startup. My tests so far are quite promissing, but I want some further testing first.

I created a ticket for this: https://bugs.eclipse.org/bugs/show_bug.cgi?id=479949

and will push a patch to Gerrit over the weekend. Maybe you can then test this locally so we can be sure that it fixes the performance issue reported by you.
Re: Quick Search feature in the Excel like filters [message #1711513 is a reply to message #1711471] Fri, 16 October 2015 14:26 Go to previous messageGo to next message
Cristi Andrei is currently offline Cristi AndreiFriend
Messages: 21
Registered: August 2015
Junior Member
Ah ,yes. I'll be out of town for the weekend, but I'll test it next week and if it would work it would be terrific.

Frankly I isolated the problem down to the ComboBoxDataProvider, which I assume scans the table and collects values from each column at startup. I noticed that if I use for example 2 data providers it takes 7 minutes, 3 -> 10 minutes etc.

The only thing to watch out for is that it doesn't affect the performance when expanding the combobox dropdown menu, since that could result in being more annoying because of the cumulated time. If it's down to a couple of milliseconds it would be ok, but if it lasts up to a couple of seconds and considering someone might check and uncheck comboboxes frequently that might be a bugger.

As you say, if the filter combo values would be initialized and cached (and stay there, as to not make this operation each and every time) when you click on the filter (to get the dropdown menu) for the first time for that specific row, I think this would work.
Re: Quick Search feature in the Excel like filters [message #1711633 is a reply to message #1711513] Sun, 18 October 2015 19:53 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2809
Registered: July 2012
Senior Member
I pushed a possible fix to Gerrit: https://git.eclipse.org/r/#/c/58404/

Now the possible combo box values are calculated and cached on first request. I tested this for bigger data sets and it looks good so far. Only if there are a lot of different menu items it will take some time to open the combo box. But the cause is not the dynamic value calculation but the populating of the combo box itself. I added a BusyIndicator to give the user feedback on the loading, since I can't improve that.

It would be great if you could verify if that fix, so we can add it to the master and publish it with 1.4.0 in the upcoming months.
Re: Quick Search feature in the Excel like filters [message #1711692 is a reply to message #1711633] Mon, 19 October 2015 10:10 Go to previous messageGo to next message
Cristi Andrei is currently offline Cristi AndreiFriend
Messages: 21
Registered: August 2015
Junior Member
Much appreciated, I'll check it out.
Re: Quick Search feature in the Excel like filters [message #1711840 is a reply to message #1711692] Tue, 20 October 2015 06:07 Go to previous messageGo to next message
Cristi Andrei is currently offline Cristi AndreiFriend
Messages: 21
Registered: August 2015
Junior Member
I tested it a bit and I must say it works quite well at improving performance. From 2 minutes and 7 second I've went down to 2 seconds.

I did notice some annoying things though:

1) When I open the ComboBox Dropdown menu for the first time, all filters are unselected. They should be all selected, like in the previous ComboBox Filter.

->This should be just inserting a selectAll() after fillCombo() when it first populates the dropdown menu with items

2) If I first filter a column and then I proceed to filter another column the second dropdown menu only populates with the items currently in the filtered table. And since the dropdown menu population happens only once it means that if I remove the filter from the first collumn, revealing all items on column 2, the dropdown of column 2 will still only show the items that were present when the table was first filtered (and when I first clicked on the column 2 dropdown).

Let me give you an example:

Column1 Column2
1 ----------- a
2 ----------- b
3 ----------- c
4 ----------- d
5 ----------- e

Say I first filter column1, checking the comboboxes of 1,2 and 5

the new table should look like this:

Column1 Column2
1 ----------- a
2 ----------- b
5 ----------- e

Now, if I click on the column2 dropdown it will naturally show a, b and e as combobox options to check.

But say I remove the filter on column1 and select all again:

Column1 Column2
1 ----------- a
2 ----------- b
3 ----------- c
4 ----------- d
5 ----------- e

Now if I click on the column2 dropdown it will still show me only a, b and e as options to check, despite b and c being present now.

I thought of 2 solutions here:

i) Either perform the operation each time we open the dropdown, which would reduce performance a lot when dealing with million row tables, but would work out well with smaller tables or tables with just lots of columns.

ii) Implement a new mechanism that notices if the table has been filtered and only does the final dropdown population if nothing is filtered.
Re: Quick Search feature in the Excel like filters [message #1711849 is a reply to message #1711840] Tue, 20 October 2015 07:01 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2809
Registered: July 2012
Senior Member
I think you have an issue with your locally overriden implementations now.

Quote:
1) When I open the ComboBox Dropdown menu for the first time, all filters are unselected. They should be all selected, like in the previous ComboBox Filter.


It does that with the NatTable codebase. I assume you override some methods for the filter support and copied the old way of performing a select all. To achieve the lazy loading it was necessary to introduce a meta value for triggering a select all. The old way needed to load all values in order to be able to select all.

You can not simply call selectAll() after fillCombo() as the editor is used in various scenarios, and as I said it work with the NatTable codebase.

Quote:
2) If I first filter a column and then I proceed to filter another column the second dropdown menu only populates with the items currently in the filtered table.


I also can't confirm that. Which collection do you use for creating the ComboBoxFilterRowHeaderComposite (the third parameter baseCollection)? If it is the FilterList, only the filtered values will be added to the combo. If you create it with the underlying list, say e.g. the SortedList or the base EventList, it should work as intended. But I agree that in case the baseCollection is a FilterList we should disable the caching.
Re: Quick Search feature in the Excel like filters [message #1711854 is a reply to message #1711849] Tue, 20 October 2015 07:33 Go to previous messageGo to next message
Cristi Andrei is currently offline Cristi AndreiFriend
Messages: 21
Registered: August 2015
Junior Member
For the first issue, yes, I think it might be local. I didn't actually apply the patch, instead I took the classes you modified and inserted them into my project as Provisory<Name>, then I continued using, extending and overriding them instead of the original ones, so the integration might not have gone as smooth as I thought.

For the second one, yes, I use FilterList, though come to think of it, I could use SortedList instead.

Re: Quick Search feature in the Excel like filters [message #1711866 is a reply to message #1711854] Tue, 20 October 2015 08:10 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2809
Registered: July 2012
Senior Member
Quote:
For the second one, yes, I use FilterList, though come to think of it, I could use SortedList instead.


Yes you should use the underlying list, otherwise you run into the described issues.

I played around a bit with disabling the caching, but the integration with the Select All item is not trivial. So as long as there is no business request for supporting FilterList based combobox values, I will skip further work on that.
Re: Quick Search feature in the Excel like filters [message #1711879 is a reply to message #1711866] Tue, 20 October 2015 08:50 Go to previous messageGo to next message
Cristi Andrei is currently offline Cristi AndreiFriend
Messages: 21
Registered: August 2015
Junior Member
Sorry, I wasn't paying enough attention, before. I actually create my ComboBoxFilterRowHeaderComposite with a ComboBoxDataProvider like this:

		FilterRowComboBoxDataProvider<Things> comboBoxDataProvider = new FilterRowComboBoxDataProvider<Things>(
				glazedListsEventLayer, sortedList, columnPropertyAccessor);

		ComboBoxFilterRowHeaderComposite<Things> filterRowHeaderLayer = new ComboBoxFilterRowHeaderComposite<Things>(
				filterList, comboBoxDataProvider, columnPropertyAccessor,
				columnHeaderLayer, columnHeaderDataProvider, configRegistry,
				false);


I also have a custom Configuration.

The baseCollection I give to the DataProvider is a SortedList.

The sorted list I create like this:

sortedList = new SortedList<Things>(filterList, null);

[Updated on: Tue, 20 October 2015 09:03]

Report message to a moderator

Re: Quick Search feature in the Excel like filters [message #1711942 is a reply to message #1711879] Tue, 20 October 2015 11:38 Go to previous messageGo to next message
Cristi Andrei is currently offline Cristi AndreiFriend
Messages: 21
Registered: August 2015
Junior Member
The "Select all" issue was a mistake on my side, I forgot to change the type of an object to the new version. Changed the FilterNatCombo (in FilterRowComboBoxCellEditor) to ProvisoryFilterNatCombo and now it works as intended.

As for the FilterList Issue, I used the eventList instead of sortedList for the DataProvider and now works.
Re: Quick Search feature in the Excel like filters [message #1711956 is a reply to message #1711942] Tue, 20 October 2015 12:13 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2809
Registered: July 2012
Senior Member
I typically create the FilterList on top of the SortedList. But nevertheless, using the base EventList should be fine as the ability to sort is not needed.
Re: Quick Search feature in the Excel like filters [message #1721327 is a reply to message #1711956] Tue, 26 January 2016 15:41 Go to previous messageGo to next message
Gal Rogozinski is currently offline Gal RogozinskiFriend
Messages: 40
Registered: June 2014
Member
Ok, I need to create something that sounds exactly like this!!
Was a contribution made?? Or do I need to do it from scratch?
Re: Quick Search feature in the Excel like filters [message #1721338 is a reply to message #1721327] Tue, 26 January 2016 16:52 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2809
Registered: July 2012
Senior Member
https://git.eclipse.org/r/#/c/63193/

IIRC the contribution is different to the discussed solution here, because it adds a new text box in the dropdown rather than using the text field. It looked already quite good, but I had some comments on the contribution that weren't answered until now. But I hope this is fixed soon so we can add it with 1.4.
Re: Quick Search feature in the Excel like filters [message #1721350 is a reply to message #1721338] Tue, 26 January 2016 17:48 Go to previous messageGo to next message
Gal Rogozinski is currently offline Gal RogozinskiFriend
Messages: 40
Registered: June 2014
Member
Thanks!!!!

When is 1.4 due to be released??
Re: Quick Search feature in the Excel like filters [message #1721353 is a reply to message #1721350] Tue, 26 January 2016 18:51 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2809
Registered: July 2012
Senior Member
Not scheduled yet since we need some intensive testing for the new features
Re: Quick Search feature in the Excel like filters [message #1721457 is a reply to message #1721353] Wed, 27 January 2016 15:23 Go to previous message
Gal Rogozinski is currently offline Gal RogozinskiFriend
Messages: 40
Registered: June 2014
Member
Thanks,

Do you maybe have a picture of the widget so that I can be sure it suits my needs?

I need to upgrade nattable to use your code and I am experiencing some difficulties...

Thanks
Previous Topic: is it possible to have scrollbar inside Nattable??
Next Topic:Cell Text Formatting in Nattable
Goto Forum:
  


Current Time: Sat Apr 17 16:16:59 GMT 2021

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

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

Back to the top