Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.0k views
in Technique[技术] by (71.8m points)

jquery - jqGrid Link Display Text

How do I set the display text on a link column in jqGrid. I want the text in every column to just say "View" with the link containing the specific Id. Here is what I currently have, but the Id get displayed in the column instead of the text "View". I was hoping to do it without passing the link html in the json returned data.

{ name: 'myId', index: 'View', edittype: 'select', formatter: 'showlink', formatoptions: {  baseLinkUrl: 'Consumer/Details', idName: 'myId'} }

My json object getting return looks like this:

select new
                                   {
                                       myId = obj.myId.ToString(),
                                       Date = String.Format("{0:d}", obj.Date),
                                       Description = obj.Description,
                                       View = "View"
                                   }
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

If I correct understand your question you can just use the following simple custom formatter instead of 'showlink' predefined formatter:

formatter: function (cellvalue, options, rowObject) {
    return '<a href="Consumer/Details?myId=' + opts.rowId + '">View</a>';
}

If you need to include some additional information in the URL of href you can use properties of the rowObject (rowObject.Date, rowObject.Description) or replace opts.rowId to the cellvalue or rowObject.myId.

You should additionally verify whether the property edittype: 'select' which you use is correct for the column. It looks like Cut&Paste error, especially because you don't use editable: true property.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...