PDA

View Full Version : How to find Record's(Row's)select/deselect inside cellclick of checkbox selection



asahoo
11 Dec 2014, 2:52 AM
Hi ,

I am using checkboxselection selection Model with checkOnly.

My requirement is to check/uncheck related rows when user check/unchecks other rows.

ie . lets say if user selects row A, i need to explicitly select row B,C with it and vice versa.

My Approach : As checkbox is the 0th column of the grid , i am listening to the cell click event of the grid.determining the record is selected or not. and process the relted row checking/unchecking accordingly.

i am using the following code block to check wheather record is selected or not

cellclick: function(view, cell, cellIndex, record){

if (view.selModel.isSelected(record)){
//Row selected
}


else
{
//Row Deselected

}
}

Issue: once i check the checkbox(selecting record) everything works fine. But once i uncheck it my else condition is not working .The reason is cellclick gets executed before the deselect, so the selection model stilll has that unselected record in my condition.

FYI:The rows gets deselected after the cellclick event execution.

Any suggestion on the same is highly appreciatble.

I know i could listen the select/deselect of rows in select/Deselect events, but when i will implement my relative check/uncheck (which user have not checked), at that time it will go for an indefinite loop.

lumberjack
15 Dec 2014, 9:19 AM
You could retrieve an array of the selected records, looping through the array to see if the record for your current row click matches one of those in the array. If it does, you know it's a selection click. If not, it's a deselection click.

Regards,
Brian

https://fiddle.sencha.com/#fiddle/f3k
f3k