html link column in jqGrid

2019-02-01 06:25发布

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

标签: jquery jqgrid
6条回答
干净又极端
2楼-- · 2019-02-01 06:40

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

colModel: [ {name:'myname', 
             edittype:'select', 
             formatter:'showlink', 
             formatoptions:{baseLinkUrl:'someurl.php', addParam: '&action=edit'}
查看更多
Explosion°爆炸
3楼-- · 2019-02-01 06:40

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

查看更多
【Aperson】
4楼-- · 2019-02-01 06:44

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

查看更多
我只想做你的唯一
5楼-- · 2019-02-01 06:53

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

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
查看更多
三岁会撩人
6楼-- · 2019-02-01 06:56

Sorry to post to an old question, but here is another option that worked for me: simply create a custom formatter and 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!

查看更多
来,给爷笑一个
7楼-- · 2019-02-01 06:58

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

查看更多
登录 后发表回答