Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
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 Go to next message
Marcin Junger is currently offline Marcin JungerFriend
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 #1691486 is a reply to message #1691462] Tue, 07 April 2015 15:03 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
Wow, what ideas people have when they are using an open API ... two rows for one item ...

I don't know where you override getCellByPosition(), but it looks like your check for columnIndex == 0 is not triggered, because you are in a scrolled state and therefore columnIndex 0 is not rendered anymore. Therefore, no spanning is triggered.

Try to remove that check or have a look at the SpanningDataLayer to see how it is implemented there.
Re: column span - disappearing [message #1691494 is a reply to message #1691486] Tue, 07 April 2015 15:40 Go to previous messageGo to next message
Marcin Junger is currently offline Marcin JungerFriend
Messages: 8
Registered: April 2015
Junior Member
Hi Dirk,
thanks for answer. I am using

SpanningDataLayer bodyDataLayer = new SpanningDataLayer(dataProvider)

as my data layer, and the code parts I pasted are from my data provider that implements ISpanningDataProvider.

And yes, the column 0 goes out of sight - but only for every second row. It would be fine not to render it for rows that do not have cell 0 spanned, but I smell a bug here that this is not called for spanned cell.

Marcin
Re: column span - disappearing [message #1691508 is a reply to message #1691494] Tue, 07 April 2015 16:53 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
Quote:
It would be fine not to render it for rows that do not have cell 0 spanned, but I smell a bug here that this is not called for spanned cell.


I don't understand what you are trying to say.

I think you need to change your code to this

if ((rowIndex % 2) != 0) {
    return new DataCell(0, rowIndex, getColumnCount(), 1);
}
Re: column span - disappearing [message #1691558 is a reply to message #1691508] Wed, 08 April 2015 07:52 Go to previous messageGo to next message
Marcin Junger is currently offline Marcin JungerFriend
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

Re: column span - disappearing [message #1691562 is a reply to message #1691558] Wed, 08 April 2015 08:11 Go to previous messageGo to next message
Marcin Junger is currently offline Marcin JungerFriend
Messages: 8
Registered: April 2015
Junior Member
Right,
so I started looking on bugs in bugzilla, and I accidentally created an empty bug report... clumsy me. I could not find an option to delete the empty bug report so I filled the details, the bug id is 464118. Sorry about that, i was not planning to report a bug without consultating it here.

Marcin
Re: column span - disappearing [message #1691565 is a reply to message #1691558] Wed, 08 April 2015 08:20 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
This is not a bug, you are not using the feature correctly. I tried to explain it on the ticket you created: https://bugs.eclipse.org/bugs/show_bug.cgi?id=464118
Re: column span - disappearing [message #1691568 is a reply to message #1691565] Wed, 08 April 2015 08:45 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
BTW, why are you subclassing NatTable? IMHO that is not a good design and might cause issues in the future when changing the implementation details.
Re: column span - disappearing [message #1691589 is a reply to message #1691568] Wed, 08 April 2015 11:10 Go to previous message
Marcin Junger is currently offline Marcin JungerFriend
Messages: 8
Registered: April 2015
Junior Member
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!
Previous Topic:Static Filter event trigger
Next Topic:Problem with word wrap in Nattable
Goto Forum:
  


Current Time: Thu Apr 18 22:00:35 GMT 2024

Powered by FUDForum. Page generated in 0.02733 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top