I've got an issue with the autoresizing, it is the following: I autoresize in two steps, first the column initializeautoresize and the the row initializeautoresize. For a standar DPI it works just fine, but for DPI greater than 100% (e.g. 125%) the rows doesn't get resized in the column header (they do in the body though).
Do you have any hint about how to solve this? I've tried almos everything I could think about and didn't find anything.
Thanks,
Jose
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
What I'm doing now is manually calculating the size (width and height) that I want for each of the columns. But I am not finding a way to register that size for each of the columns. Do you have any hints here?
Thanks,
Jose
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
sorry for the late reply. We are currently very busy on moving from Sourceforge to Nebula.
I looked into the AutoResizeRowCommand and there only the body layer is enabled for automatic row resizing. Maybe something to take care of. Feel free to modify the AutoResizeRowCommand in a way that works for your use case and contribute it. :)
The size of a row/column is stored within a SizeConfig in the DataLayer. You can either set the size you prefer directly via DataLayer or fire a RowResizeCommand/ColumnResizeCommand.
Hope this helps.
Greez,
Dirk
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks for the answer Dirk! About the DPI I didn't try your solution yet, but for the resizing of the columns I did it the following way, I'd like to share in case someone wants to achieve the same (don't know if it is going to be useful to someone but you never know).
So, what I wanted was that nattable columns take as much space as they have avaliable (that means, the width of the table was as big as the width of the parent. But if I set nattable.width = parent width what happened is that even though the table has its parent's width, the columns were the same size. Also, I wanted each of the column to have a specific weight, since I don't want them to be the same size, so I have to add a specific weight to each of the columns. So what I did was the following:
1st) Create a method to actually set the weights. By default the method will return 1 so all the columns have the same weight.
protected int getColumnIndexWeight(int columnIndex) {
// Here we provide a weight to the columns
// column Index 0 = 5
// column Index 1 = 2
// Column index 2 = 13
// Wtotal = 20
int[] columnWeight = { 5, 2, 13 };
return columnWeight[columnIndex];
}
2nd) I overrided the createControl method I added a listener that does the following:
final Composite container = parent;
int calculateWeight = 0;
for (int i = 0; i < getColumnPropertyAccessor().getColumnCount(); i++) {
calculateWeight = calculateWeight + getColumnIndexWeight(i);
}
final int totalWeight = calculateWeight;
parent.addControlListener(new ControlListener() {
@Override
public void controlResized(ControlEvent e) {
Point containerSize = container.getSize();
natTable.setSize(containerSize);
for (int i = 0; i < getColumnPropertyAccessor()
.getColumnCount(); i++) {
float percentage = (float) getColumnIndexWeight(i)
/ (float) totalWeight;
float weight = (float) containerSize.x * percentage;
getDataLayer()
.setColumnWidthByPosition(i, (int) weight - 3);
}
}
@Override
public void controlMoved(ControlEvent e) {
// nothing to do here...
}
});
And this does all the trick, even if you resize the window, the table will always fit inside its parent. (getDataLayer() is a method I created that returns the bodydatalayer).
What I found is that if I set a minimum size here, lets say a width of 450, I was having a weird behavior with the horizontal scrolling bar, basically if I moved the scroll bar to the right, it auto-jumped to the very left and if I drag it again it will come but the table will not scroll. Please note that while the minimum if not reached the scroll bar behaves correctly when they appear (for example if the user manually resizes a column to be bigger). Is this maybe a bug with scrolling or maybe I missed to register something?
Thanks,
Jose
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'm currently working on a percentage sizing feature for NatTable. With this you can achieve your goals by setting the size in percentage values and tell the DataLayer to calculate in percentages. I will post here when I checked into Nebula trunk as I'm not sure if it is stable yet.
Hi,
I've got an issue with the autoresizing, it is the following: I autoresize in two steps, first the column initializeautoresize and the the row initializeautoresize. For a standar DPI it works just fine, but for DPI greater than 100% (e.g. 125%) the rows doesn't get resized in the column header (they do in the body though).
Do you have any hint about how to solve this? I've tried almos everything I could think about and didn't find anything.
Thanks,
Jose
Hi again,
What I'm doing now is manually calculating the size (width and height) that I want for each of the columns. But I am not finding a way to register that size for each of the columns. Do you have any hints here?
Thanks,
Jose
Hi Jose,
sorry for the late reply. We are currently very busy on moving from Sourceforge to Nebula.
I looked into the AutoResizeRowCommand and there only the body layer is enabled for automatic row resizing. Maybe something to take care of. Feel free to modify the AutoResizeRowCommand in a way that works for your use case and contribute it. :)
The size of a row/column is stored within a SizeConfig in the DataLayer. You can either set the size you prefer directly via DataLayer or fire a RowResizeCommand/ColumnResizeCommand.
Hope this helps.
Greez,
Dirk
Thanks for the answer Dirk! About the DPI I didn't try your solution yet, but for the resizing of the columns I did it the following way, I'd like to share in case someone wants to achieve the same (don't know if it is going to be useful to someone but you never know).
So, what I wanted was that nattable columns take as much space as they have avaliable (that means, the width of the table was as big as the width of the parent. But if I set nattable.width = parent width what happened is that even though the table has its parent's width, the columns were the same size. Also, I wanted each of the column to have a specific weight, since I don't want them to be the same size, so I have to add a specific weight to each of the columns. So what I did was the following:
1st) Create a method to actually set the weights. By default the method will return 1 so all the columns have the same weight.
2nd) I overrided the createControl method I added a listener that does the following:
And this does all the trick, even if you resize the window, the table will always fit inside its parent. (getDataLayer() is a method I created that returns the bodydatalayer).
What I found is that if I set a minimum size here, lets say a width of 450, I was having a weird behavior with the horizontal scrolling bar, basically if I moved the scroll bar to the right, it auto-jumped to the very left and if I drag it again it will come but the table will not scroll. Please note that while the minimum if not reached the scroll bar behaves correctly when they appear (for example if the user manually resizes a column to be bigger). Is this maybe a bug with scrolling or maybe I missed to register something?
Thanks,
Jose
Hi Jose,
I'm currently working on a percentage sizing feature for NatTable. With this you can achieve your goals by setting the size in percentage values and tell the DataLayer to calculate in percentages. I will post here when I checked into Nebula trunk as I'm not sure if it is stable yet.
There is currently a bug in NatTable where you can't scroll within one cell, so if the cell is bigger then the visible part, you are not able to scroll. https://bugs.eclipse.org/bugs/show_bug.cgi?id=379931
Greez,
Dirk