Forum


15:35

16/12/2008

Maybe this should go under feature request? I'll put it here in case it is helpful to somebody else someday.
I did this for jqGrid 3.5, but it should be the same for other versions. This is a small hack to jquery.fmatter.js to allow specification of a target when using links in a grid:
//begin url target mod : adam@PigsLipstick.com
var op = {target:opts.target };
var target = "";
if(!isUndefined(opts.colModel.formatoptions)) {
op = $.extend({},op,opts.colModel.formatoptions);
target = 'target=' + op.target;
}
//end url target mod (note inclusion of target variable in url)
if(!isEmpty(cellval)) {
$(el).html("<a " + target + " href=\\"" + cellval + "\\">" + cellval + "</a>");
}else {
$(el).html(isValue(cellval) ? cellval : "");
}
};
and then the corresponding piece in the colModel to specify the formatoptions:
{name:'link', index:'link', width: 300, editable:true,editoptions:{size:45}, formatter:'link',formatoptions:{target:”_new”}}
Best Regards,
Adam
03:04

Moderators
30/10/2007

Hello,
Thank you Adam - good addition. Will be added.
Regards
Tony
For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.
01:18

11/05/2009

Hi Adam,
I ahve copied your code into my jquery.fmatter.js file, and have included the formatoptions in my colmodel (using "_new" as my target), but the url still opens in the same window, and not a new one.
Any ideas?
Thanks!
---------------------------------------------------------------------------
$.fn.fmatter.link = function(el,cellval,opts) {
//begin url target mod : adam@PigsLipstick.com
var op = {target:opts.target };
var target = “”;
if(!isUndefined(opts.colModel.formatoptions)) {
op = $.extend({},op,opts.colModel.formatoptions);
target = 'target=' + op.target;
}
//end url target mod (note inclusion of target variable in url)
if(!isEmpty(cellval)) {
$(el).html(”<a ” + target + ” href=\\”" + cellval + “\\”>” + cellval + “</a>”);
}else {
$(el).html(isValue(cellval) ? cellval : “”);
}
};and then the corresponding piece in the colModel to specify the formatoptions:
{name:'link', index:'link', width: 300, editable:true,editoptions:{size:45}, formatter:'link',formatoptions:{target:”_new”}}
Best Regards,
Adam
Most Users Ever Online: 715
Currently Online:
108 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
OlegK: 1255
markw65: 179
kobruleht: 144
phicarre: 132
YamilBracho: 124
Renso: 118
Member Stats:
Guest Posters: 447
Members: 11373
Moderators: 2
Admins: 1
Forum Stats:
Groups: 1
Forums: 8
Topics: 10592
Posts: 31289
Newest Members:
, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66