Table with no row header [message #1066823] |
Thu, 04 July 2013 14:11 |
Cedric Moonen Messages: 274 Registered: August 2009 |
Senior Member |
|
|
Hello,
I'm trying to create a table which doesn't have a row header (so simply a column header and a data section). I initially started with a GridLayer, but this layer always display the row header.
So, I changed to a CompositeLayer and created the column layer and body layer, but now my table is not editable anymore (which was the case when using a gridLayer).
Here is a code snippet:
EventPropertyBodyLayerStack bodyLayer = new EventPropertyBodyLayerStack(
eventType.getProperties(), propertyNames);
// Column header
DefaultColumnHeaderDataProvider columnHeaderDataProvider = new DefaultColumnHeaderDataProvider(
propertyNames, propertyToLabelMap);
ILayer columnHeaderLayer = new ColumnHeaderLayer(
new DefaultColumnHeaderDataLayer(columnHeaderDataProvider),
bodyLayer, bodyLayer.getSelectionLayer());
CompositeLayer compositeLayer = new CompositeLayer(1, 2);
compositeLayer.setChildLayer(GridRegion.BODY, bodyLayer, 0, 1);
compositeLayer.setChildLayer(GridRegion.COLUMN_HEADER,
columnHeaderLayer, 0, 0);
final ColumnOverrideLabelAccumulator columnLabelAccumulator = new ColumnOverrideLabelAccumulator(
bodyLayer.getDataLayer());
bodyLayer.getDataLayer().setConfigLabelAccumulator(
columnLabelAccumulator);
registerColumnLabels(columnLabelAccumulator);
IConfigRegistry configRegistry = new ConfigRegistry();
natTable = new NatTable(this, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL,
compositeLayer, false);
natTable.setConfigRegistry(configRegistry);
natTable.addConfiguration(new DefaultNatTableStyleConfiguration());
natTable.addConfiguration(new EventPropertyEditConfiguration());
natTable.configure();
Any idea what I might be doing wrong ? If some additional code is needed, I can provide it.
Thank you,
Cédric
|
|
|
|
|
|
|
Re: Table with no row header [message #1066974 is a reply to message #1066968] |
Fri, 05 July 2013 10:10 |
Cedric Moonen Messages: 274 Registered: August 2009 |
Senior Member |
|
|
Hello Dirk,
Sorry for my beginner questions, I just started to use the control, so I'm sometimes a bit lost...
Quote:Again, are you sure that the DefaultEditBindings are included in your edit configuration? By default it is added in the DefaultGridLayerConfiguration, which you don't have as you don't use the GridLayer. So if you don't add it manually, it wouldn't be there!
Ok, I misunderstood your previous reply, I thought that you were talking about the way to configure the edit properties like shown in the examples (specifying which columns are editable, adding combobox cell editors, ...).
Indeed, I didn't do that. So, now if I add that configuration (in fact I add DefaultEditBindings and DefaultEditConfiguration) to my CompositeLayer, I can edit my fields in the table. However the selection is now behaving in a very strange way: it always disappear. So if I edit a cell and conform (for instance by hitting enter), then the cell selection disappear (which means I can't navigate my table using keyboard anymore).
Here is what I do:
CompositeLayer compositeLayer = new CompositeLayer(1, 2);
compositeLayer.setChildLayer(GridRegion.COLUMN_HEADER,
columnHeaderLayer, 0, 0);
compositeLayer.setChildLayer(GridRegion.BODY, bodyLayer, 0, 1);
compositeLayer.addConfiguration(new DefaultEditBindings());
compositeLayer.addConfiguration(new DefaultEditConfiguration());
Do I add the configurations on the correct layer ?
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04626 seconds