1

I would like to have a check box in a filter row for certain columns.

To do this I've added a ComboCellEditor with specified check box values to choose from.

final ComboBoxCellEditor comboBoxCellEditor = new ComboBoxCellEditor(checkBoxValues);
comboBoxCellEditor.setMultiselect(true);
comboBoxCellEditor.setUseCheckbox(true);
comboBoxCellEditor.setMultiselectTextBracket("", "");
configRegistry.registerConfigAttribute(EditConfigAttributes.CELL_EDITOR, comboBoxCellEditor,
        DisplayMode.EDIT, region);

This is allowing me to select the values I would like to filter with. After selecting them it then stores them in the cell as [first value, second value, third value]. This means that no rows are brought back as nothing in the columns matches the full string.

With this in mind I assume I would have to change the text to some form of regular expression and set the TextMatchingMode to REGULAR_EXPRESSION. I've been trying to implement a DisplayConverterbut I can't figure out how this should be done.

I've looked at the examples to try and work this out but I can't find one that covers my case. There's StaticFilterGridExample which is a normal combo box that selects one value (this I've gotten working correctly) or ExcelLikeFilterRowExample which adds a checkbox filter to every column. I would like to do this only to individual columns so I can't use that layer.

What is the best method of achieving this?

Michael
  • 3,411
  • 4
  • 25
  • 56

1 Answers1

1

IIUC you want to mix the Excel-like-filter with simple filters with checkboxes and/or textfields. Is that correct?

This is currently not supported out of the box in NatTable. You will need to create your own mixture of the both default implementations to make it work.

Dirk Fauth
  • 4,128
  • 2
  • 13
  • 23
  • Yes that's correct. We want editable text, combo box and check box filters. By default implementations do you mean a new layer that handles this or an implementation in the registry configuration? – Michael Jul 08 '20 at 16:28
  • A filter strategy – Dirk Fauth Jul 08 '20 at 17:45
  • well, looking into the example you probably need a new layer similar to the `ComboBoxFilterRowHeaderComposite` and a new filter strategy similar to `ComboBoxGlazedListsFilterStrategy`. – Dirk Fauth Jul 09 '20 at 05:24
  • This was it. I managed to do it by setting the registry configuration to use the combo box cell editor and to create a custom `ComboBoxGlazedListsFilterStrategy`. I can now have a variety of filter types work all together in one table. Thanks for the help! – Michael Jul 10 '20 at 10:37
  • Perfect! We take contributions if you like ;-) – Dirk Fauth Jul 10 '20 at 11:19
  • I would offer but I'm not sure if it's done in the best way. If I get some time spare I'll see if I can :) – Michael Jul 13 '20 at 09:37