PDA

View Full Version : Help with Checkbox Selection Model



jshaw
14 Jul 2010, 1:58 PM
I am using checkboxSelectionModel in a Grid to permit user to select all items using the checkbox on top; or select one or more items by clicking the checkbox.
1) Cliking checkbox on top - no issues - all rows are selected
2) Clicking the checkbox directly in a given row does not seem to work, only clicking in any other cell in that row works
3) If the user wants to select multiple rows, then she needs to do shift+click or control+click.
This is non-intuitive - users want to directly click on one or more checkboxes.
I am using Ext-3.1.2

Are there config options that enable the desired behavior? Any guidance on how I can enable multiple selection by directly clicking on checkboxes will be great.

jshaw
14 Jul 2010, 2:44 PM
I noticed that turning off DragDrop gets me closer to the desired behavior. With DD turned off, I can select one or more by clicking directly on the checkbox.
The only remaining issue:
While multiple rows are selected, if I click a cell of any row, that row becomes selected, and all the other selected rows become deselected.

How do I override this behavior?

cvillaronga
23 Jul 2010, 7:50 AM
Hi jsHaw,

may be, you can try using checkOnly : false in tour selection model.

checkOnly (http://www.sencha.com/deploy/dev/docs/source/CheckboxSelectionModel.html#cfg-Ext.grid.CheckboxSelectionModel-checkOnly) : Boolean

true if rows can only be selected by clicking on the checkbox column (defaults to false).

Justin.Parmar
29 Aug 2010, 10:44 PM
cvillaronga, as u have suggested the default value for checkOnly is false only.
but this is not the solution for Jshow's problem.
i think what actually he (and also I) want is when you select a row in grid with checkBoxSelectionModel, that row should be selected with preserving previous selection.

j-joey
30 Aug 2010, 7:31 AM
maybe this helps:



...

myCustomSelection = function( sm, row, keep, rec ) {
if ( sm.getSelections().length > 0 ) {
sm.suspendEvents();
sm.selectRecords( rec, true );
sm.resumeEvents();
return false;
}
}

grid.selModel.on( 'beforerowselect', myCustomSelection );

...