Reputation: 505
In my jqGrid implementation, we have a subgrid with a dropdown and we want to change the icon in a cell on change of that dropdown. I have used the Formatter
to generate the icons shown in the picture below. But now I want to add/remove the icon images from the cell. Is this possible to do? I'd greatly appreciate any help/ideas for that? We are using the jqGrid for ASP .NET in this project.
function formatActionGridIcons(cellValue, options, rowObject) {
if (cellValue.indexOf("_") == -1) return '';
var arr = cellValue.split('_');
var icon1 = arr[0];
var icon2 = arr[1];
var icon3 = arr[2];
//if (icon1 == "R")
var cellHtml = getIconHtml(icon1) + getIconHtml(icon2) + getIconHtml(icon3);
return cellHtml;
}
function getIconHtml(icon) {
if (icon == null || icon == "") return "";
var result = GetIconPath(icon);
if (typeof (result) === "undefined" || result == "")
return "";
else
return "<img src='" + GetIconPath(icon) + "' width='18px' height='18px' />";
}
function unformatActionGridIcons(cellValue, options, cellObject) {
return $(cellObject.html()).attr("originalValue");
}
Upvotes: 0
Views: 1497
Reputation: 222017
You can use setCell
to modify the cell with icons. It calls internally the formatter of the cell to generate HTML fragment which will be set in the grid. So you need just use the same format of data setCell
for its 3-d parameter like you use in the input of the grid.
Upvotes: 1