开发者

Create a jqGrid link with just the id

I can see how to create a jqGrid link using:

colModel: [ {name:'myname', 
             formatter:'showlink', 
             formatoptions:{baseLinkUrl:'someurl.php', addParam: '&action=edit'}

This creates a request like /someu开发者_C百科rl.php?id=XX&action=edit and the display text will be the value of myname.

But in our case we don't need the myname text - our display text will be hard coded. We don't want to have to pass any additional data down in our JSON request - but it seems you need a JSON attribute for each column. How can we have a link without the add'l JSON column?


The formatter 'showlink' like all other formatter are used to format the data loaded in jqGrid from server or from the local data. So in case of your example you will not have 'myname' text (the column name) in the link but the cell value from the grid.

So if you want to use predefined formatter 'showlink' you have to fill the column data with the text which want to see in the link. You can do this either inside of your JSON data or filling/overwriting the text after the page are loaded for example inside of loadComplete event handle:

loadComplete: function() {
    var grid = $("list");
    var ids = grid.getDataIDs();
    for (var i = 0, idCount = ids.length; i < idCount; i++) {
        grid.setCell(id, 'myname', 'My text for link');
    }
}

You can use also custom formatter and custom unformatter instead of 'showlink' predefined formatter. Then you can define the text of link like you want without filling any data in the grid.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜