How to configure NatTable FilterComboBox to have a different DataProvider for each column

54
June 12, 2019, at 09:30 AM

In my NatTable I am using a ComboBoxFilterRowHeaderComposite similar to ExcelLikeFilterRowCustomTypesExample. It works fairly well however the combo box filtering adds too many items in large tables to allow for easy filtering. I am trying to fix this by only filling the combo with certain items, however; in my table some columns are just for types or operations which have a limited amount of different values and I would like to add all options for those. While for other columns I'd like to only add root items.

To achieve this I think I need to modify the comboBoxDataProvider, however; for the full effect that I want it would require a different dataprovider for some columns.

Is this the correct approach? And if so how would I go about doing this?

This is how I am currently configuring my combo box composite:

    ComboBoxFilterRowHeaderComposite<GroupedPerfRecord> filterRowHeaderLayer =
            new ComboBoxFilterRowHeaderComposite<GroupedPerfRecord>(
                    bodyLayerStack.getFilterList(),
                    bodyLayerStack.getBodyDataLayer(),
                    bodyLayerStack.getSortedList(),                     
                    columnPropertyAccessor, columnHeaderLayer,
                    columnHeaderDataProvider, configRegistry, false);
    final IComboBoxDataProvider comboBoxDataProvider = filterRowHeaderLayer.getComboBoxDataProvider();
    filterRowHeaderLayer.addConfiguration(new ComboBoxFilterRowConfiguration() {
        {
            this.cellEditor = new FilterRowComboBoxCellEditor(comboBoxDataProvider, 5);
            this.filterIconPainter = new ComboBoxFilterIconPainter(comboBoxDataProvider, GUIHelper.getImage("filter"), null);
        }
    });
Answer 1

With a default filter row that has combo boxes for single selection you would use different IComboBoxDataProvider for each column. But you have chosen the ComboBoxFilterRowHeaderComposite that has a different filtering mechanism in the back to support multi selection and handling of Select All similar to well-known spreadsheet applications. So there is no build-in mechanism that would allow to simply configure the desired behavior.

But there is a constructor in the ComboBoxFilterRowHeaderComposite that takes a FilterRowComboBoxDataProvider as parameter. So you could provide your own implementation of a FilterRowComboBoxDataProvider (maybe subclass the GlazedListsFilterRowComboBoxDataProvider) and implement the desired behavior in getValue() based on the column index.

READ ALSO
How to pass data to BottomSheetDialogFragment?

How to pass data to BottomSheetDialogFragment?

I have a BottomSheetDialogFragment classLooks like this:

46
In spring batch, how to insert a piece of code just after reading a list of item by bulk, with given list of item as parameter?

In spring batch, how to insert a piece of code just after reading a list of item by bulk, with given list of item as parameter?

I'm using spring batch in chunk mode for processing itemsI read them by bulk(6000 items by bulk), process them one by one, and write them all

32
Save and Restore workbench on E4

Save and Restore workbench on E4

in my RCP 3x-based Client-/Server-Application, I save the workbench state (e

31
What causes grails application to create more threads in some deployments

What causes grails application to create more threads in some deployments

Not 100% sure how to ask thisSkip to last paragraph for the actual question, the rest is background information

38