Passing different column id in jqgrid showLink formatter

烂漫一生 提交于 2019-12-11 07:31:18

问题


I had a bean object with me in the colmodel of jqgrid. the object hold two attributes name and id. I used a showLink formatter to form the hyperlink in one of the column. Now i have names the colum with object.name and on click i want to send the id in URL. Any inputs on how to work on this. Any inputs could help me

code :

colModel :[ 
      {name:'xxx', label:'xxx', width:200,align:'left'},
      {name:'yyy', label:'yyy', width:110,align:'left'}, 
      {
          name:'zzz',
          label:'zzz',
          width:100,
          sorttype:'int',
          formatter:'currency',
          formatoptions:{decimalSeparator:".", thousandsSeparator: ",", decimalPlaces: 0, prefix: "$ "},
          align:'center'
      }, 
      {name:'aaa', label:'aaa', width:80,align:'left'}, 
      {name:'bbb', label:'bbb', width:100,align:'left'}, 
      {
          name:'strategies.name',
          label:'strategies',
          width:160,
          align:'left',
          formatter:'showlink',
          formatoptions:{baseLinkUrl:'MyLink.html',addParam: '',showAction:'',idName:'id'}
      }]
jQuery("#gridtableid").jqGrid('filterToolbar',{defaultSearch : "cn",stringResult: true,searchOnEnter : false});

Thanks in advance....


回答1:


In JQgrid, you can call a javascript function and do any required formatting . You have the entire row data to play with it.

What needs to be done is call a function showlink in your case and remove formatoptions from that row. HAve a separate js function showlink as below and return the prepared link back to the grid.

function showLink(cellvalue, options, rowObject) {


var link = "<a href ='<a href=\"http://www.w3schools.com&id='"+rowObject.columnid+"\">'+ rowObject.columnName + "</a>"; 

}


来源:https://stackoverflow.com/questions/9379639/passing-different-column-id-in-jqgrid-showlink-formatter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!