Unanswered: Capturing each checkbox selection change event on Grid
I'm new to GSX 3 and trying to figure out how checkbox selection events inn a Grid work in the new model. I just want to get notified on each checkbox check/uncheck change so I can set a boolean property on the model that was clicked. I don't want to get a list of all selected items like the SelectionChangedEvent seems to provide. This was really easy in the 2.x model but I'm not grasping it from the examples. Ther checkbox grid example doesn't seem to handle any events. Thanks for any help.
Couldn't you just use the list of models returned by the selection changed event and iterate over them toggling the field in question?
We use this event to determine the enabled/disabled state of buttons extraneous to the grid that act on the grid (e.g., Delete).
You are talking about modifying the underlying model object in the grid by hijacking the selection checkbox - something that is probably possible, but arguably not how the CheckboxSelectionModel was designed to be used.
I don't think that works in multi select mode. How do you know when something is de-selected ? From my testing you basically get a list of all selected items. So I think I would have to do what darrell suggested and keep my own selected list, and compare to the one I get from the event. In 2.x you could bind a checkbox column to a boolean property on the model. It was real easy.
The selection event fires every time a checkbox is selected or deselected. I'm not saying that this is the right way to go, but in a selection event handler, you can ask the selection model for a list of the selected items and ensure that any model not in that list receives a false boolean property and true otherwise. Of course, this is an O(n) operation for every checkbox click and certainly not a good solution.
Why don't you just render a CheckBoxCell for the boolean property on your model and make an editable grid? http://www.sencha.com/examples/#Exam...needitablegrid
I stand by my previous statement that you are using CheckBoxSelectionModel in a capacity for which it was not really designed.