My server provides the following json string:
{
"total":3,
"page":1,
"records":52,
"rows":[
{"cell":[
"6789",
"Veridien Dynamics",
"ver01",
"Description of Site: ver01",
"1986a594-bb12-4a4a-a70b-4b85251fd268",
"UKSODMBHANU01",
6440],
"id":120}
......
]
}
In my grid, I would like to have a link for each row. The link is built using custom formatter. The url for the link needs to include the id (e.g. 120). I cannot obtain the value of id from cellvalue
, options, nor the rowObject
in my custom formatter. Since id is not part of the 'cell', I don't know how to obtain this value to construct the url.
Following is part of my grid definition :
$("#list").jqGrid({
url:'http://mydomain:8080/myserver/api/v1/data-grid.json',
loadBeforeSend: function(xhr) {
xhr.setRequestHeader("Authorization",'Basic xxxxxxxxxxxxxxxxxxxxxxxxx');
return xhr;
},
datatype: "json",
jsonReader : {
root: "rows",
page: "page",
total: "total",
records: "records",
repeatitems: true,
cell: "cell",
id: "id"
},
colNames:['Customer ID','Customer','Site ID','Site', 'Server ID','Server Name',
'XML Size','id'],
colModel :[
{name:'customerID',editable:false},
{name:'customerName',editable:false},
{name:'siteID',editable:false,width:60, align:'center'},
{name:'siteDescription',editable:false,align:'center'},
{name:'serverID',editable:false,width:150,align:'right'},
{name:'serverName',editable:false, width:150,align:'right'},
{name:'xmlSize',editable:false, align:'right'},
{name:'id', index:'id', editable:false,
align:'center',formatter:that.xmlLinkFormatter},
],
......
}
Following is my xmlLinkFormatter
, everything works fine if I hard code the id value here to be part of the targetURL
.
xmlLinkFormatter:function(cellvalue, options, rowObject){
var targetURL = "http://mydomain:8080/myServer/data/showXml/"+
IwantIDValue here;
var link = "<a href='javascript: void(0)' onclick=\"window.open('" +
targetURL + "');\">View XML</a>";
return link;
}