html link column in jqGrid

前端 未结 6 1243
轮回少年
轮回少年 2020-12-24 06:13

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

相关标签:
6条回答
  • 2020-12-24 06:53

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

    0 讨论(0)
  • 2020-12-24 06:59

    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
    
    0 讨论(0)
  • 2020-12-24 07:03

    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

    0 讨论(0)
  • 2020-12-24 07:04

    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'}
    
    0 讨论(0)
  • 2020-12-24 07:09

    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!

    0 讨论(0)
  • 2020-12-24 07:09

    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

    0 讨论(0)
提交回复
热议问题