JimmyD
JimmyD

Reputation: 2759

Cell dropdown does not work when hiding row numbers

I have a Nattable that can hide his row numbers. now when I hide the row numbers it does not show the dropdown in a cell.

I use this code to hide the row numbers:

if (showRowNumbers) {
      compositeGridLayer = new GridLayer(bodyLayer, finalHeaderRow, rowHeaderLayer, cornerLayer);
    } else {
      compositeGridLayer = new CompositeLayer(1, 2);
      compositeGridLayer.setChildLayer(GridRegion.COLUMN_HEADER, columnHeaderLayer, 0, 0);
      compositeGridLayer.setChildLayer(GridRegion.BODY, bodyLayer, 0, 1);
      compositeGridLayer.setChildLayer(GridRegion.COLUMN_HEADER, finalHeaderRow, 0, 0);
    }

For adding the drop down to the cell we register it using:

ComboBoxCellEditor comboBoxCellEditor = new ComboBoxCellEditor(phases, -1);
comboBoxCellEditor.setMultiselect(false);
comboBoxCellEditor.setUseCheckbox(false);
comboBoxCellEditor.setFreeEdit(false);

configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_PAINTER, new ComboBoxPainter(),
  DisplayMode.NORMAL, "phaseDropDown");

comboBoxCellEditor.setIconImage(GUIHelper.getImage("plus"));
configRegistry.registerConfigAttribute(EditConfigAttributes.CELL_EDITOR, comboBoxCellEditor, DisplayMode.EDIT,
  "phaseDropDown");

configRegistry.registerConfigAttribute(CellConfigAttributes.DISPLAY_CONVERTER, new DefaultDisplayConverter() {

  @Override
  public Object canonicalToDisplayValue(Object canonicalValue) {

    return super.canonicalToDisplayValue(canonicalValue);
  }
}, DisplayMode.NORMAL, "phaseDropDown");

How can I hide the row numbers without removing the drop down in the table?

Upvotes: 1

Views: 60

Answers (1)

Dirk Fauth
Dirk Fauth

Reputation: 4231

Not sure what you mean with "hiding row numbers". Hiding would imply that you want to do this dynamically. And the approach you are showing would not be dynamically.

If you mean you want to provide two different compositions, one with row numbers and one without, the approach would be correct. You use a different composition. What I don't understand is why you set a column header twice with different layers.

The next question, what do you mean with "does not show the dropdown"? Don't you see the small triangle or does the combobox not open? I guess you mean the combobox does not open on click. I suppose the reason is that you forgot to register the necessary editing configurations on the newly created CompositeLayer. The GridLayer is created with the default configuration. On the CompositeLayer you do not set any configuration. So actually even print, export and alternate row colors will not work as they are simply not configured.

You need to register the DefaultEditConfiguration and the DefaultEditBindings on the CompositeLayer. This is explained in our NatTable Documentation|Editing. And I'm sure we also have some examples that cover editing in a non-grid composition.

Upvotes: 1

Related Questions