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

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

问题描述

如何在 jqGrid 的链接列上设置显示文本.我希望每一列中的文本只说查看",链接包含特定的 ID.这是我目前拥有的,但 Id 显示在列中,而不是文本视图"中.我希望在不传递 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.Date, rowObject.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' 对于该列是否正确.它看起来像 Cut&Paste 错误,尤其是因为您没有使用 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天全站免登陆