First of all, the name of the JavaScript library you are trying to use is: jqGrid . Throughout the documentation or on the main side, you will find the same name written in the same form.
To your main question. It seems you can just use the onCellSelect to catch the click event on the image or just click on any cell. The onCellSelect callback parameter e is the event object , and e.target will be the element that was clicked.
Demo demonstrates how you can use it.

I used jQuery UI as the original background image to lock.
formatter: function () { return "<a href='#'><span class='ui-icon ui-icon-locked'></span></a>" }
Clicking on the image changed the image by changing the class on the <span> element from "ui-icon-locked" to "ui-icon-unlocked" :
onCellSelect: function (rowid, iCol, cellcontent, e) { var $dest = $(e.target), $td = $dest.closest('td'); if ($td.hasClass("clickableTitle")) { if ($dest.hasClass("ui-icon-locked")) { $dest.removeClass("ui-icon-locked").addClass("ui-icon-unlocked"); } else { $dest.removeClass("ui-icon-unlocked").addClass("ui-icon-locked"); } } }
You can easily change the code if you prefer to have <img> instead of the background image in <span> .
Oleg
source share