PDA

View Full Version : Grid grouping



cyChop
8 Dec 2010, 4:49 AM
Hello there,

I have a question here: I have defined a grouping on a grid. It works just fine when I use a basic field (long, String), but when I use a complex object which I have created, the grid sometimes seems unable to distinguish between several objects, though I have implemented an equals() (which is never called, by the way).

I don't understand why it should work in some places and not others.

So would you please mind explaining me how the Grid/GridView/GroupingStore determines if two lines belong to the same group? I have skimmed the code, but could not find it.

Thanks,

(using GXT 2.1)

sven
8 Dec 2010, 4:54 AM
GroupingView calls toString on the object that is under the dataindex of the group and compares that. (getGroup method of GroupingView)

cyChop
8 Dec 2010, 5:17 AM
OK, that explains why it doesn't work.

Isn't that hasardous? I mean, two instances may have the same toString though not being significantly equal (that being the case in my project, and I'm quite afraid of side-effects when I change the toString...).

I am quite curious about the constraints that lead you to do this rather than using your equalWithNull (if I remember well the name) method. After a quick look through the code of groupingview, it seems to be a mere implementation choice. Might that be a bug, or do I just misuse it?

Thanks for your quick answer anyway, you saved me some trouble! Once again...

sven
8 Dec 2010, 5:21 AM
Why should it be a bug? I dont get this argumentation.

It was designed this way for a long time. Its probably wrong and should be changed, however this is a braking change i cannot do at the moment. You will need to extend GroupingView and override getGroup so it returns something that works for you.

cyChop
8 Dec 2010, 5:29 AM
Why should it be a bug? I dont get this argumentation.
According to me, two objects are not equal because their toString is equal, this is all I mean.

Anyway, your answer already helped me solve my problem. I just asked the question in case you want to consider it for future releases.

sven
8 Dec 2010, 5:41 AM
The GroupingView should be completly rewritten from scratch, probably something for GXT3.