|
|
Re: SelectCellCommand issue with TextPainter calculateByTextHeight [message #1065499 is a reply to message #1065342] |
Wed, 26 June 2013 07:30 |
Marius Pop Messages: 3 Registered: June 2013 |
Junior Member |
|
|
Hi Dirk ,
thank you for your quick reply.
As for the sample I modified the "Getting Started" (_001_Getting_Started) from nattable examples in the following way :
I added more persons to the list , so it will need scrolling :
private IDataProvider setupBodyDataProvider() {
List<Person> people = new ArrayList<Person>();
Person mickey = new Person(100, "Mickey Mouse", new Date(1000000));
for (int i = 0; i < 50; i++) {
people.add(mickey);
}
Person bond = new Person(100, "James Bond", new Date(1000000));
for (int i = 0; i < 50; i++) {
people.add(bond);
}
propertyToLabels = new HashMap();
propertyToLabels.put("id", "ID");
propertyToLabels.put("name", "First Name");
propertyToLabels.put("birthDate", "DOB");
propertyNames = new String[] { "id", "name", "birthDate" };
return new ListDataProvider(people,
new ReflectiveColumnPropertyAccessor(propertyNames));
}
and the NatTable creation I modified to have automatic calculation of text height:
NatTable natTable = new NatTable(parent, false);
natTable.setLayer(gridLayer);
natTable.addConfiguration(new DefaultNatTableStyleConfiguration() {
{
cellPainter = new TextPainter(false, true, 5, false, true);
}
});
natTable.configure();
Now when this sample is run try to search with the search dialog for "James" and it will not navigate to to James unless you search 3 or 4 times.
Hope this is enough to reproduce the behavior , if not I can post the entire sample code.
Regards,
Marius
|
|
|
Re: SelectCellCommand issue with TextPainter calculateByTextHeight [message #1065504 is a reply to message #1065499] |
Wed, 26 June 2013 07:56 |
Dirk Fauth Messages: 2903 Registered: July 2012 |
Senior Member |
|
|
Thanks for providing the sample. I was able to reproduce and my thoughts on it were correct.
By using the specified TextPainter for calculating the height, the row height of every row in the grid gets resized. It would also occur if there would be only some rows that get resized.
As I said before, we only calculate what we see and do not calculate the row heights and columns widths initially. This is because we follow the concept of a virtual table and want to support large data sets.
So what happens is, to move the row into the viewport we need to calculate the coordinates. This is done by adding the row heights of the other rows. Now that these rows are rendered, by setting calculateHeight, all rows get resized, and therefore the selected cell moves out of the viewport again. After a few times the correct row heights for all visible rows are set correctly, therefore it works then.
We have some kind of race condition here, because ideally we would need to resize first and then move the row into the viewport. Which would violate the virtual concept. Another option would be to try to have something like "let the selected row STAY regardless what happens next".
As you hopefully can see, this is not a trivial issue to solve. Could you please open a ticket for this, adding a link to this forum post and maybe attach your whole example? This way also other committers would be able to have a look into this issue. We definitely need to discuss a possible solution.
Thanks,
Dirk
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04087 seconds