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 08:39  |
Eclipse User |
|
|
|
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 #1691589 is a reply to message #1691568] |
Wed, 08 April 2015 07:10  |
Eclipse User |
|
|
|
Hmm now that I think of subclassing - I will rethink this design. Initial thought was that i would have to change some functionality related to displaying two rows per item. That was before i gained the knowledge I have, and indeed what I only do is I configure the nat table.
Regarding my initial problem, it is now solved and works as expected . For those who work with column span and face similar issue, I added working example as an attachment.
Many thanks for your help, Dirk!
|
|
|
Goto Forum:
Current Time: Mon Jun 23 09:34:37 EDT 2025
Powered by FUDForum. Page generated in 0.04799 seconds
|