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.
$grid->setColModel()
gives no information. In the same way you could post: "some code...". Which format exactly have input data which you use? You can use Fiddler or developer Tools of IE to trace HTTP traffic. You should include as example one row of input data. Do you useloadonce: true
option or not? Do you usejsonmap
in the column orjsonReader
option in jqGrid? How exactly the column are defined incolModel
? You can open source code in web browser to see which code are executed. – Liquescentloadonce: true
, and i just have this line regarding colmodel:$grid->setColModel()
– Margo