jqGrid Link Display Text
How do I set the display text on a link column in jqGrid. I want the text in every column to just say "View" with the link containing the specific Id. Here is what I currently have, but the Id get displayed in the column instead of the text "View". I was hoping to do it without passing the link html in the json returned data.
{ name: 'myId', index: 'View', edittype: 'select', formatter: 'showlink', formatoptions: { baseLinkUrl: 'Consumer/Details', idName: 'myId'} }
My json object getting return looks like this:
select new
{
开发者_StackOverflow myId = obj.myId.ToString(),
Date = String.Format("{0:d}", obj.Date),
Description = obj.Description,
View = "View"
}
If I correct understand your question you can just use the following simple custom formatter instead of 'showlink' predefined formatter:
formatter: function (cellvalue, options, rowObject) {
return '<a href="Consumer/Details?myId=' + opts.rowId + '">View</a>';
}
If you need to include some additional information in the URL of href
you can use properties of the rowObject
(rowObject.Date
, rowObject.Description
) or replace opts.rowId
to the cellvalue
or rowObject.myId
.
You should additionally verify whether the property edittype: 'select'
which you use is correct for the column. It looks like Cut&Paste error, especially because you don't use editable: true
property.
精彩评论