Nattable column resize [message #1719954] |
Wed, 13 January 2016 13:33 |
christy jovita Messages: 22 Registered: June 2014 |
Junior Member |
|
|
Hi,
I have a Nattable with 25 column with different columnwidth. I set the columnwidth using datalayer.setColumnWidthByPosition(i, 30) method.
When I resize the nattable for the first time, the column width gets changed and layed out properly. But after refreshing the table, resizing does not work anymore. In my custom resizing listener method I set the proper column width in datalayer.setColumnWidthByPosition(i, 50) , but still it does not resize the nattable.
The values of the width of each column is based on its parent composite.
What am I doing wrong ? Should I have to set some configuration to nattable after setting the columnwidth?
[Updated on: Wed, 13 January 2016 13:45] Report message to a moderator
|
|
|
|
|
|
|
Re: Nattable column resize [message #1719974 is a reply to message #1719966] |
Wed, 13 January 2016 14:15 |
christy jovita Messages: 22 Registered: June 2014 |
Junior Member |
|
|
I tried the percentage resizing, but it still has the same problem .It is resized it for the first time, but once the refresh method(in which the layers and configuration is set. ) is called and the resizing doesnt work anymore.
I have different settings to show different types of nattable, so once the settings are chosen , the refresh method is called.
Note: Different types of nattable, I mean nattable with different number columns and data
[Updated on: Wed, 13 January 2016 14:19] Report message to a moderator
|
|
|
|
|
Re: Nattable column resize [message #1719991 is a reply to message #1719982] |
Wed, 13 January 2016 15:53 |
christy jovita Messages: 22 Registered: June 2014 |
Junior Member |
|
|
This is the main method that is called when doing refresh/ opening the form , I do the following :
public void createform(SheetType type){
dataLayer = new SpanningDataLayer(this.bodyDataProvider);
cSheetBody.addControlListener(createControlListener(type, dataLayer,cSheetBody,columnNames.length));
dataLayer.registerCommandHandler(new VisualRefreshCommandHandler());
selLayer = new SelectionLayer(dataLayer);
viewportLayer = new ViewportLayer(selLayer);
// Create HeadLayer
colLayer = new ColumnHeaderLayer(
headData.getHeaderDataLayer(),
viewportLayer,
selLayer);
ColumnGroupHeaderLayer colgroupLayer = new ColumnGroupHeaderLayer(colLayer, selLayer, headData.getColumnGroupModel());
table.setColumnHeaderLayer(colLayer);
compLayer = new CompositeLayer(1, 2);
compLayer.registerCommandHandler(new VisualRefreshCommandHandler());
// Cell Editable
selLayer.addConfiguration(new CustomEditBindings(this));
viewportLayer.addConfiguration(new DefaultEditConfiguration());
viewportLayer.addConfiguration(new AbstractRegistryConfiguration() {
@Override
public void configureRegistry(IConfigRegistry configRegistry) {
configRegistry.registerConfigAttribute(
EditConfigAttributes.CELL_EDITABLE_RULE,
IEditableRule.ALWAYS_EDITABLE);
}
});
this.bodyDataProvider.setViewportLayer(viewportLayer);
this.bodyDataProvider.setNatTable(natTable);
natTable.addLayerListener(eListeners.createSelectionListener());
// Set Position of Child Layers
natTable.registerCommandHandler(new VisualRefreshCommandHandler());
compLayer.setChildLayer(GridRegion.COLUMN_HEADER, colgroupLayer, 0, 0);
compLayer.setChildLayer(GridRegion.BODY, viewportLayer, 0, 1);
final DataLayer headerDataLayer = (DataLayer) colLayer.getBaseLayer();
// create Header Accumulator
ColumnOverrideLabelAccumulator columnLabelAccumulator = new ColumnOverrideLabelAccumulator(
headerDataLayer);
headerDataLayer.setConfigLabelAccumulator(columnLabelAccumulator);
// Set Vertical Header Columns
CellLabelFactory.setVerticalHeaderColumns(type, columnLabelAccumulator);
// create Column Accumulator
CustomBodyCellOverrideLabelAccumulator bodyColumnLabelAccumulator = new CustomBodyCellOverrideLabelAccumulator(
dataLayer, this.bodyDataProvider, type);
bodyColumnLabelAccumulator.setFactory(this);
dataLayer.setConfigLabelAccumulator(bodyColumnLabelAccumulator);
// printCommandHandler = new PrintCommandHandler(compLayer);
// compLayer.registerCommandHandler(printCommandHandler);
printCommandHandler = new PrintCommandHandler(natTable);
natTable.registerCommandHandler(printCommandHandler);
compLayer.registerCommandHandler(new ExportCommandHandler(compLayer));
// set Container Layer
table.setCompositeLayer(compLayer);
// set Layer to NatTable
natTable.setLayer(compLayer);
// Configure Table
CellLabelFactory.attachToolTip(natTable, group, eListeners);
// natTable.setLayout(new GridLayout());
natTable.setBackground(SWTResourceManager
.getColor(255, 255, 255));
natTable.addConfiguration(new AbstractRegistryConfiguration() {
@Override
public void configureRegistry(IConfigRegistry configRegistry) {
//register a custom formatter to the body of the grid
//you could also implement different formatter for different columns by using the label mechanism
configRegistry.registerConfigAttribute(
ExportConfigAttributes.EXPORT_FORMATTER,
new CustomExportFormatter(),
DisplayMode.NORMAL,
GridRegion.BODY);
configRegistry.registerConfigAttribute(
ExportConfigAttributes.EXPORT_FORMATTER,
new CustomExportFormatter(),
DisplayMode.NORMAL,
GridRegion.COLUMN_GROUP_HEADER);
configRegistry.registerConfigAttribute(
ExportConfigAttributes.EXPORT_FORMATTER,
new CustomExportFormatter(),
DisplayMode.NORMAL,
GridRegion.COLUMN_HEADER);
}
});
// Drag/Drop Support
if(filter.getModel().getNotEditable())
{
enableDragDrop();
}
// natTable.addOverlayPainter(new NatTableBorderOverlayPainter(GUIHelper.getColor(0,0,0),true));
// Configure
natTable.configure();
GridDataFactory.fillDefaults().grab(true, true).applyTo(natTable);
}
and Inside my control resize listener,
class CustomControlListener implements ControlListener{
public CustomControlListener(){
}
@Override
public void controlResized(ControlEvent e) {
this.dataLayer = CellItemFactory.setDefaultColumnWidth2(this.dataLayer, this.type, this.cSheetBody,this.columns); // method to calculate column width for every resizeand its sets the columnwidth in the datalayer
setDataLayer(dataLayer);
if(getBodyDataProvider() == null){
setBodyDataProvider((SpanningBodyDataProvider)dataLayer.getDataProvider());
}
}
@Override
public void controlMoved(ControlEvent e) {
}
}
If I call the createform(type) in controlresize(), the resizing works fine but as you said before it is not the correct practice to set the layers and configuration everytime during the refresh/resize.
I do not want to call createform(type) method in the resize method.
Hope this information helps to find out whats wrong with the behaviour.
[Updated on: Wed, 13 January 2016 15:54] Report message to a moderator
|
|
|
|
Re: Nattable column resize [message #1720064 is a reply to message #1720000] |
Thu, 14 January 2016 08:26 |
christy jovita Messages: 22 Registered: June 2014 |
Junior Member |
|
|
I will start creating from scratch. But Could you please give an idea what should be there in controlresized() method when resizing is done?
Quote: But NatTable is not a container and therefore setting a layout is wrong.
I am not setting the layout. That code is commented out.
[Updated on: Thu, 14 January 2016 08:34] Report message to a moderator
|
|
|
|
Powered by
FUDForum. Page generated in 0.03791 seconds