Search code examples
javanattable

Add a multi-select ComboBoxCellEditor in a Filter Row


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?


Solution

  • 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.