Reputation: 1343
I have a row1 selected and highlighted then am selecting row2 getting highlighted; when i select row2 i want only row2 highlighted with css and row1 should be defaulted or may be for row1 i want to remove css. Please help
onSelectRow: function(id){
var rowData = $(this).getRowData(id);
var memberId= rowData['memberId'];//replace name with any column
if(id!==lastSel){
$(this).find('.ui-state-highlight').css({background:'#80BFFF'});
lastSel=id;
}
}
Upvotes: 1
Views: 3980
Reputation: 1662
It appears that you are actually modifying the CSS of the "selected" row. In order to properly remove the "selected" highlight of the previously selected element, you would have to also remove the css modification. I would suggest putting your highlight color in a selected class, and then add/remove based on that:
CSS
.selected{
background-color:#80BFFF !important;
}
JS
onSelectRow: function(id){
var rowData = $(this).getRowData(id);
var memberId= rowData['memberId'];//replace name with any column
if(id!==lastSel){
$(this).find(".selected").removeClass('selected');
$('#results_table').jqGrid('resetSelection', lastSel, true);
$(this).find('.ui-state-highlight').addClass('selected');
lastSel=id;
}
}
Upvotes: 4