How can I get column info (name or ID) in my custom-format function?
Some code in grid.php:
$grid->dataType = 'json';
$grid->setColModel();
My custom format function
function formatPdfLink(cellValue, options, rowObject) {
var cellHtml = "<a href='" + cellValue + "' title='" + [show column Name here] + "' ><img src='../img/PDF_icon.png ' /></a> ";
return cellHtml; }
Javascript code excerpts, found in generated page (view source):
jQuery(document).ready(function($) {
jQuery('#grid').jqGrid({
"jsonReader": {
"repeatitems": false,
"subgrid": {
"repeatitems": false
}
},
"xmlReader": {
"repeatitems": false,
"subgrid": {
"repeatitems": false
}
},
"colModel": [{ {
"name": "pdf_1",
"index": "pdf_1",
"sorttype": "string",
"label": "C",
"sortable": false,
"width": 25,
"align": "center",
"search": false,
"formatter": formatPdfLink,
"unformat": unformatPdfLink,
"editoptions": {
"size": 100
},
"editable": true
}
}]
I have tried to use rowObject.columnName
but it won't work!
NB: I am not using loadonce: true
PS: please let me know if more details are needed.