Vertical scrollbar shifts to the top after user clicks on cell at the bottom [message #1806369] |
Wed, 08 May 2019 08:32 |
Sharmila Naik Messages: 6 Registered: May 2019 |
Junior Member |
|
|
HI,
We are using NatTable to display the formsheet data. Our NatTable contains more that 30 columns. Also the rows gets added dynamically to the table.
Since the NatTable with large data does not fit in the screen, it displays both horizontal and vertical scrollbars.
The issue we are facing is, when user double clicks on some cell at the bottom (it opens up some dialog as per our requirement) , the cell gets selected but the vertical
scrollbar moves to the top.User has to scroll down to find which cell he selected. This is annoying to the user working on huge NatTable data.
Our requirement is when user clicks on any cell in the table, the scroll bar should not move automatically and cell should remain focused.
I am using below code to achieve this.
natTable.refresh();
dataLayer.resetRowHeightConfiguration(false);
if (col < 0 || row < 0) {
gif.viewportLayer.moveCellPositionIntoViewport(0, 0);
} else {
CellItem ci = (CellItem) gif.bodyDataProvider.getDataValue(selectionCol, selectionRow);
CellItem mergeParent = null;
if (ci.getMergeParent() != null) {
mergeParent = (CellItem) gif.bodyDataProvider.getDataValue(ci.getMergeParent().x, ci.getMergeParent().y);
row = ci.getMergeParent().y;
}
gif.viewportLayer.moveCellPositionIntoViewport(col, row);
int positionInViewport = gif.viewportLayer.getRowPositionByIndex(row);
while (positionInViewport > 1 && row < gif.bodyDataProvider.getRowCount() - 1) {
row++;
positionInViewport--;
}
gif.viewportLayer.moveCellPositionIntoViewport(col, row);
if (ci.getMergeParent() != null) {
gif.selLayer.setSelectedCell(mergeParent.getColumn(), mergeParent.getRow());
} else {
gif.selLayer.setSelectedCell(selectionCol, selectionRow);
}
if(!gif.natTable.isDisposed())
gif.natTable.redraw();
}
Can you please help me to understand if I am missing anything here.
Thanks,
Sharmila
|
|
|
|
|
|
Re: Vertical scrollbar shifts to the top after user clicks on cell at the bottom [message #1806552 is a reply to message #1806460] |
Fri, 10 May 2019 10:45 |
Sharmila Naik Messages: 6 Registered: May 2019 |
Junior Member |
|
|
Hi Dirk,
Thak you for your reply.
I removed unwanted refresh calls from my code. But, I am still facing issue of scrollbar jumping upward (by 2-3 rows).I will try to explain my code.
Below is the method we have written which will set focus on the selected cell and also adjust the scrollbar shift. On double click action listener we are calling this method.
public void moveCellToTop(int col, int row) {
int selectionCol = col;
int selectionRow = row;
if (col < 0 || row < 0) {
gif.viewportLayer.moveCellPositionIntoViewport(0, 0);
}
else
{
gif.viewportLayer.moveCellPositionIntoViewport(col, row);
int positionInViewport = gif.viewportLayer.getRowPositionByIndex(row);
while (positionInViewport > 1 && row < gif.bodyDataProvider.getRowCount() - 1) {
row++;
positionInViewport--;
}
gif.viewportLayer.moveCellPositionIntoViewport(col, row);
gif.selLayer.setSelectedCell(selectionCol, selectionRow);
if(!gif.natTable.isDisposed())
gif.natTable.redraw();
}
}
When I click on the cell, the dialog pops up but the scrollbar jumps a bit (by 2-3 rows) in upward direction. Hence user has to scroll down manually till the selected cell.
Which is not desirable behaviour for the customer.
From my understanding, method "viewportLayer.moveCellPositionIntoViewport" decided how much scrollbar should shift itself.
So if input parameters to the method are col=5, row=7 then , scrollbar should adjust itself in such a way that the 7th row should be visible to the user.
If my understanding is correct, the method is not behaving correctly. Am I missing anything here?
Also to be noted, the issue is not consistently reproduced. And most of the time on the first double click the issue occurs. When user closes the dialog and
double clicks second time, the scrollbar remains steady.
Can you please provide your valuable inputs on this?
Thanks,
Sharmila
|
|
|
|
Powered by
FUDForum. Page generated in 0.03282 seconds