Can I Update An Image In Jqgrid Cell
Hi I have gone through various link to update a cell value like here also here I need to change the image which I put through a custom formatter as soon as user clicks on the image
Solution 1:
You can use event
parameter of onCellSelect
callback. event.target
will be element, clicked by user. Below is the example of the code:
onCellSelect: function (iRow, iCol, content, event) {
var cmName = $(this).jqGrid("getGridParam", "colModel")[iCol].name,
target = event.target;
if (cmName === "col_image" && target.tagName.toUpperCase() === "IMG") {
if (condition) { // some kind of testing
target.src = "img/loading_completed.png";
target.title = "Click to view data";
// one can use $(target).attr alternatively
//$(target).attr({
// src: "img/loading_completed.png",
// title: "Click to view data"
//});
} else {
target.src = "img/loading_error.png";
target.title = "No data available";
// one can use $(target).attr alternatively
//$(target).attr({
// src: "img/loading_error.png",
// title: "No data available"
//});
}
}
}
Post a Comment for "Can I Update An Image In Jqgrid Cell"