1

Is there any way to display a static column value ( ex - "ClickHere" will display in the all rows with the "Details" as column header) in Jqgrid? i am using spring MVC Jackson support for populate the jqgrid by using a jsonReader. i just need to have a static string as a column that not comes with the JSON.

Ex -

Student Name | Detail |


  XXXX  | clickhere
  YYYY  | clickhere

I need to have 'clickHere' string hardcoded in a jqgrid column while i used studentName from the json object. Can this is doable?

Please let me know your thoughts. Thank you in advance

Sam
  • 2,055
  • 6
  • 31
  • 48

2 Answers2

3

I don't use spring MVC myself, but to create a column with the static text 'Click here' you can define it with respect of the custom formatter:

{ name:'Details', width:60, sortable:false, search:false,
  formatter:function(){
      return 'Click here';
  },
  unformatter:function(){return '';}
}

The definition of the unformatter is optional. Probably you will not need it. It's depend on how you read (it you ever do it) the data from grid.

It can be that formatter:'showlink' of some other form of link is what you really want to do. In the case you can find the answer on your question here (see the demo).

Community
  • 1
  • 1
Oleg
  • 220,925
  • 34
  • 403
  • 798
  • Thank you very much for the answer. i found one of your [demo](http://www.ok-soft-gmbh.com/jqGrid/CustomLink.htm) here. it was also really helpfull. Thanks again. – Sam Jun 23 '11 at 11:54
  • @Sam: You are welcome! Yes, the old demo use the same idea, but it was written before. It uses `getDataIDs` and then `$("#"+ids[i]+" a",myGridNode);` in the loop which could be slow in case of large grid. Now I would rewrote the statement at least to `$("a:first",gridRows.namedItem(ids[i]));` where `var gridRows = myGridNode.rows;` are defined above the loop. – Oleg Jun 23 '11 at 12:20
0
{ name:function(){return 'Click here';},
  width:60, sortable:false, search:false,
  formatter:'showlink', formatoptions: { baseLinkUrl: 'javascript:', showAction: "somefunction('", addParam: "');"}      
}

By using this way u can use all other option as well like formatoptions

Raj
  • 351
  • 2
  • 13
  • 30