Reputation: 3046
I have a jqgrid
in which i have multiple cell selected(Ctrl key) which is in yellow highlight.
Now on a button click i have to clear all the cell highlighted.But if a row is selected it should be the same. Need only the cell highlight to be removed.
Any possibilities?
Upvotes: 0
Views: 409
Reputation: 221997
It seems be small modification of the answer on your previous question. If mySelection
parameter holds the information about selected cells then one can unselect the cells in the following event handler:
$("#clearCellSelection").button().click(function () {
var key, item, $td, rows = $grid[0].rows, p = $grid.jqGrid("getGridParam"),
mySelection = p.mySelection,
idPrefix = p.idPrefix;
// click without Ctrl key pressed
// we need unselect all
for (key in mySelection) {
if (mySelection.hasOwnProperty(key)) {
item = mySelection[key];
$td = $(rows.namedItem(idPrefix + item.id).cells[item.indexOfColumn]);
$td.removeClass("ui-state-highlight").removeAttr("aria-selected");
}
}
p.mySelection = {};
});
The corresponding modified demo is here.
One should be careful if the grid contains sortable: true
option or if columnChooser
allows the user to change the order of the columns. In the case one can't use indexOfColumn
property of the selected cell information. Instead of that one have to use colName
property and find the index of the column with the name colName
in colModel
. The index should be used instead of indexOfColumn
.
Upvotes: 1