Below is my code for jqGrid, i\'d like to select row or highlight the current row, when i check
a particular checkbox inside jqgrid row. right now onSelec
Put this at the and of your JS code in order to run selection when clicking a checkbox
$("#list1").find('input[type=checkbox]').each(function() {
$(this).change( function(){
var colid = $(this).parents('tr:last').attr('id');
if( $(this).is(':checked')) {
$("#list1").jqGrid('setSelection', colid );
$(this).prop('checked',true);
}
return true;
});
});
example UPDATED AGAIN: http://jsfiddle.net/vCWNP/
edit: this also should be done every time a new row is added. let me know if something else is to be fixed ;]
It seems to me, that you could solve your problem very easy. What you try to do is already implemented in the jqGrid. If you remove the column name:'',index:''
which has empty name
, which is NOT PERMITTED and include an additional jqGrid parameter multiselect:true
all will work like you as need.
One simple way to do that:
jQuery(".jqgrow td input").each(function () {
jQuery(this).click(function () {
$("#grid").jqGrid('setSelection', $(this).parents('tr').attr('id'));
});
});
on your onSelectRow function add:
var flag = jQuery(this).find('#'+id+' input[type=checkbox]').prop('checked');
if(flag){
jQuery(this).css('background-color', 'red' )// row will be in red if checkbox is selected, you have to find out the current row here
}