View Full Version : Custom SelectionModel for a GroupingGrid

26 Aug 2010, 7:25 AM
Hi there,

I think I can solve this problem on my own with a non-elegant solution (though I'm only beginning examining the tracks I've found). Still, it would be silly to design a wheel, wouldn't it?

So here's my goal: I have a grouping grid, and I want to customize it in the following ways:
- the grouping cannot be undone or changed (but all columns will be .setGroupable(false));
- if a line is selected, the whole group must be selected.

The second part is what worries me most, though, as I said, I'm hoping to find a solution on my own. Yet, if someone has already done this, I'm curious to know how they managed to do it.


26 Aug 2010, 7:28 AM
For the second part. Cannot you simple add a Select event listener to the SelectionModel and if that fires, you select all models that have the same groupingproperty?

26 Aug 2010, 11:53 PM
OK, it works quite fine, and it's much easier than what I was trying (using Element and NodeList like in the Check Grouping grid example).

Still, there might be a bug: selectionModel.addListener(Events.SelectionChanged, new Listener<SelectionEvent<?>>() {...}) caused a ClassCastException. I add to use the .addSelectionChangedListener(...) method. Oughtn't these two methods be equivalent?

Thanks for your help anyway!

27 Aug 2010, 12:49 AM
It would be:

selectionModel.addListener(Events.SelectionChange, new Listener<SelectionChangedEvent<M>>() {...})

27 Aug 2010, 2:17 AM
Alright, thank you sven. The Javadoc could be updated then: http://dev.sencha.com/deploy/gxtdocs/com/extjs/gxt/ui/client/widget/selection/AbstractStoreSelectionModel.html

Thanks for your help!