Is it possible to use RowSelectionModel in combination with GroupByLayer ? [message #1770286] |
Wed, 09 August 2017 16:05 |
Chris Lewold Messages: 13 Registered: July 2017 |
Junior Member |
|
|
What I basically want to achieve is, that the user can select only rows, not single cells - so I wanted to use the RowSelectionModel.
However I also need the group-by feature.
As long as I do no grouping everything works fine. Once I drag a column to the "group by header area" I get ClassCastExceptions because GroupByObject cannot be cast to "MyRowBean".
The problem sounds obvious to me - RowSelectionModel likely expects just beans of a given type, and GroupByLayer suddenly introduces completely different beans for the GroupBy tree.
Did anyone ever mix these two features successfully ?
[Updated on: Wed, 09 August 2017 16:07] Report message to a moderator
|
|
|
|
|
Re: Is it possible to use RowSelectionModel in combination with GroupByLayer ? [message #1771374 is a reply to message #1771004] |
Thu, 24 August 2017 12:28 |
Chris Lewold Messages: 13 Registered: July 2017 |
Junior Member |
|
|
Uhm, well .....
IRowIdAccessor is a teplated class, with my "row data bean" as template argument.
I do not get the CCE - it happens before getRowId is invoked. I also cannot use e.g. Object as template argument, as then I cannot instantiate the RowSelectionModel, which itself is templated.
But ..... both you and Didier are of course correct. What I can do is
* not to use template arguments for both the IRowIdAccessor and the RowSelectionModel
* check the type of the passed class in getRowId
* return the proper id in case it is "MyDataBean" and hashcode otherwise. (basically I want to avoid hashCode as it is not necessarily unique).
Imho still a little bit hackish ;-) - but it seems to work ....
[Updated on: Thu, 24 August 2017 13:22] Report message to a moderator
|
|
|
|
Re: Is it possible to use RowSelectionModel in combination with GroupByLayer ? [message #1771431 is a reply to message #1771425] |
Fri, 25 August 2017 05:50 |
Chris Lewold Messages: 13 Registered: July 2017 |
Junior Member |
|
|
package org.eclipse.nebula.widgets.nattable.data;
import java.io.Serializable;
public interface IRowIdAccessor<R> {
public Serializable getRowId(R rowObject);
}
isn't R a template argument? Shouldn't this be the same as in the RowSelectionModel and shouldn't the "RowDataBean" class be used there?
... well maybe there is my misunderstanding - but if it is used like this, then you get the CCE I described (when activating grouping) .... so no, there is no other framework, this is native NatTable
Either way - if I use Object instead, and do the downcast in getRowId, then I'm able to handle the exception. Possibly it's not exactly as intended, but it works quite well.
[Updated on: Fri, 25 August 2017 05:51] Report message to a moderator
|
|
|
|
Powered by
FUDForum. Page generated in 0.02615 seconds