jqGrid链接显示文本 [英] jqGrid Link Display Text

查看:140
本文介绍了jqGrid链接显示文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在jqGrid的链接列上设置显示文本.我希望每一列中的文字都只说查看",并包含包含特定ID的链接.这是我当前拥有的,但是ID显示在列中,而不是文本"View".我希望在不传递json返回数据中的链接html的情况下做到这一点.

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'} }

我的json对象得到的回报看起来像这样:

My json object getting return looks like this:

select new
                                   {
                                       myId = obj.myId.ToString(),
                                       Date = String.Format("{0:d}", obj.Date),
                                       Description = obj.Description,
                                       View = "View"
                                   }

推荐答案

如果我正确理解了您的问题,则可以使用以下简单的自定义格式化程序代替"showlink"预定义格式化程序:

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>';
}

如果需要在href的URL中包括一些其他信息,则可以使用rowObject(rowObject.DaterowObject.Description)的属性或将opts.rowId替换为cellvaluerowObject.myId

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.

您还应该验证所使用的属性edittype: 'select'对于该列是否正确.看起来像剪切并粘贴"错误,尤其是因为您没有使用editable: true属性.

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.

这篇关于jqGrid链接显示文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆