Home » Eclipse Projects » NatTable » column span - disappearing(Problem with column span when scrolling column out of sight)
column span - disappearing [message #1691462] |
Tue, 07 April 2015 12:39 |
Marcin Junger Messages: 8 Registered: April 2015 |
Junior Member |
|
|
Hi all,
I am new to NatTable, went through tutorial at Vogella and other articles....
I am using NatTable in the following way: I display two rows per data item, in the first row I display several columns that have short data - like timestamp, name etc. In the second row, I set the column span of 0th cell to column span = number of columns. In that column I display couple of lines of data.
This looks good, something like this:
|Name|Timestamp|Col2|Col3|
|John |13:45 |bla |bla |
| multiline data |
Now, I do not see column 3, I have to scroll to see it. So I scroll horizontally and... the moment column 1 disappears out of sight, column span disappeares, and instead of multiline data I see empty cells for Timestamp|Col2|Col3|.
Here is my code behind data provider:
/**
* For even rows, this method returns data per column; For odd rows, the request for column 0 returns {@link LogEntry#getData()}, and "" for others.
*
* @param columnIndex Column index, 0 based. Corresponds to {@link #COLUMNS}.
* @param rowIndex Row index, 0 based.
*/
@Override
public Object getDataValue(int columnIndex, int rowIndex) {
if ((rowIndex % 2) == 0) {
int rowNum = rowIndex / 2;
return ColumnsProvider.COLUMNS[columnIndex].getValue(data.getContent().get(rowNum));
} else {
int rowNum = (rowIndex - 1) / 2;
if (columnIndex == 0) {
return LogEntryDbFields.DATA.getValue(data.getContent().get(rowNum));
}
return "";
}
}
/**
* Controls column span: column that shows {@link LogEntry#getData()} has full span.
*
* @param columnIndex Column index, 0 based. Corresponds to {@link #COLUMNS}.
* @param rowIndex Row index, 0 based.
*/
@Override
public DataCell getCellByPosition(int columnIndex, int rowIndex) {
if (columnIndex == 0 && (rowIndex % 2) != 0) {
return new DataCell(columnIndex, rowIndex, getColumnCount(), 1);
}
return new DataCell(columnIndex, rowIndex, 1, 1);
}
@Override
public int getRowCount() {
return data.getContent().size() * 2;
}
Any ide how to solve my problem? Or maybe I can achieve my goal (two rows per data entry, different columns in each of those rows)?
Kind regards
Marcin
|
|
| | | |
Re: column span - disappearing [message #1691558 is a reply to message #1691508] |
Wed, 08 April 2015 07:52 |
Marcin Junger Messages: 8 Registered: April 2015 |
Junior Member |
|
|
I prepared simplistic example showing what the problem is. Forget about my previous code with multiple rows per item etc. The "disappearing column" behavior can be observed on very basic implementation.
In the attachement I uploaded class that builds up a nat table - to place it on parent container, call SimpleNatTableExample.buildinstance(parent).
In the example, I create simple grid with header. The grid has 10 columns and 100 rows. Column 1 has column span of 2. When I run the example, if grid is not scrolled (screenshot scr01.png), everything looks like expected: column 0 has span of 2 and has value of "COL0 ...", header has COL0 and COL1. Now I scroll to the right.... and just when in header COL0 is out of sight the grid shows what is on screenshot scr02.png. This is not expected behavior of column span functionality.
The expected behavior is presented on mockup expected.png.
The expected behavior is that when column 0 has column span of 2, it is visible when header column 0 or column 1 are visible. So when header column 0 disappears from sight, column 0 still needs to be rendered as in reality - it is in sight because it has span of two.
I do not know how to explain it clearer. I think this behavior is a bug. What is your opinion?
OR
Maybe I am doing something wrong?
[Updated on: Wed, 08 April 2015 08:18] Report message to a moderator
|
|
| | | | |
Goto Forum:
Current Time: Thu Sep 26 03:34:34 GMT 2024
Powered by FUDForum. Page generated in 0.04812 seconds
|