Forum

November 2nd, 2014
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_TopicIcon
formatter link - specify target
31/03/2009
15:35
Avatar
akremedy
California, USA
Member
Members
Forum Posts: 37
Member Since:
16/12/2008
sp_UserOfflineSmall Offline

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:

    $.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

01/04/2009
03:04
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

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.

21/05/2009
01:18
Avatar
casperd
Member
Members
Forum Posts: 76
Member Since:
11/05/2009
sp_UserOfflineSmall Offline

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


Forum Timezone: Europe/Sofia

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.com

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information