jQuery jqGrid中的html链接列

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1166076/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 10:48:38  来源:igfitidea点击:

html link column in jqGrid

jqueryjqgrid

提问by Danny

Is it possible have a html link in a column with jqGrid, I can't find any example in the documentation?

是否可以在带有 jqGrid 的列中包含 html 链接,我在文档中找不到任何示例?

采纳答案by Craig Stuntz

Yes, use a formatter, either a custom formatter or Predefined Formatter.

是的,使用格式化程序,自定义格式化程序或预定义格式化程序

回答by Randy Klingelheber

Here's the sample colModel configuration from Craig's link to jqGrid formatting help. It specifies the formatter as showLinkand the url and params are specified with formatoptions.

这是来自 Craig 链接到 jqGrid 格式帮助的示例 colModel 配置。它将格式化程序指定为showLink并且使用formatoptions指定 url 和 params 。

colModel: [ {name:'myname', 
             edittype:'select', 
             formatter:'showlink', 
             formatoptions:{baseLinkUrl:'someurl.php', addParam: '&action=edit'}

回答by Patrick

Sorry to post to an old question, but here is another option that worked for me: simply create a custom formatterand return an anchor tag (a good option if you need really granular control of the link):

很抱歉发布一个旧问题,但这是另一个对我有用的选项:只需创建一个自定义格式化程序并返回一个锚标记(如果您需要对链接进行真正的精细控制,这是一个不错的选择):

function returnMyLink(cellValue, options, rowdata, action) 
{
    return "<a href='/Controller/Action/" + options.rowId + "' >Click here</a>";
}   

Look in the rowdata for the data returned by your query. Hope this helps someone!

在 rowdata 中查找查询返回的数据。希望这可以帮助某人!

回答by beakersoft

within the json data i am using for the grid, i just send html code back with a href tag in, that works for me

在我用于网格的 json 数据中,我只是将带有 href 标签的 html 代码发回,这对我有用

回答by yei

If you use xml data, you can add a dummy column in your query to display it in the grid

如果你使用xml数据,你可以在你的查询中添加一个虚拟列来显示在网格中

grid:

网格:

colModel :[{name:'EDIT',edittype:'select',formatter:'showlink', width:5,xmlmap:"Edit",formatoptions:{baseLinkUrl:'someurl.php', addParam: '&action=edit'}},

query:

询问:

select f1,f2,f3, 'Edit' as Edit FROM table

回答by user214553

in xml I use entity &lt; instead of < in the a tag like this &lt;a href="dest">my link&lt;/a> and works fine with jqgrid 3.6

在 xml 我使用实体 < 而不是像这样的 a 标签中的 < <a href="dest">my link</a> 并且在 jqgrid 3.6 中工作正常