1

I have this jqgrid definition and I'm trying to open the selected document in a new Window.

My final urls should like these:

http://localhost/XPagesSortableSearchResults.nsf/xPerson.xsp?documentId=9D93E80306A7AA88802572580072717A&action=openDocument

and also I need to generate this type of url:

http://localhost/XPagesSortableSearchResults.nsf/$$OpenDominoDocument.xsp?documentId=9D93E80306A7AA88802572580072717&action=openDocument


$().ready(function(){
jQuery("#list2").jqGrid({
        url:'./xGrid7.xsp/peoplejson',
        datatype: "json",
        colNames:['InternetAddress','#','Name','OfficeCountry'],
        colModel:[                              
            {name:'InternetAddress',index:'InternetAddress', width:200},
            {name:'@position',index:'@position', width:50,sorttype:'int'},
            {name:'$17',index:'$17', width:200},
            {name:'OfficeCountry',
                   width:200,
                   formatter:editLinkFmatter
                  // formatter:'showlink',
                  // formatoptions:{ baseLinkUrl:'xPerson.xsp',addParam: '&action=openDocument', idName:'documentId'}
            }
        ],
        jsonReader: {
            repeatitems: false,
            id: '@unid',
            root: function (obj) {
                  if ($.isArray(obj)) {
                       return obj;
                  }
                  if ($.isArray(obj.items)) {
                    return obj.items;
                  }
                  return [];
                     },
             page: function () { return 1; },
             total: function () { return 1; },
             records: function (obj) {
                    if ($.isArray(obj)) {
                        return obj.length;
                    }
                    if ($.isArray(obj.items)) {
                        return obj.items.length;
                    }
                    return 0;
            }
        },
        caption: "JSON Example",
        height: 500,
        gridview: true,
        loadonce: true,
        ignoreCase: true,
        rowNum: 50, 
        rowList: [50, 100, 500, 1000],
        pager: '#pager2'
        }).jqGrid('filterToolbar', {stringResult: true, defaultSearch: 'cn', searchOnEnter: false});

Note my Json object looks like this and I'm not using the documentId I need on my url as part of my ColModel; the value I need is @unid

        [
      {
          "@entryid":"1-B933790B1DC265ED8025725800728CC5",
          "@unid":"B933790B1DC265ED8025725800728CC5",
          "@noteid":"1E76E",
          "@position":"1",
          "@read":true,
          "@siblings":40000,
          "@form":"Person",
          "$17":"Aaron, Adam",
          "InternetAddress":"consurgo@compleo.net",
          "OfficeCountry":"Namibia"
      },
      {
          "@entryid":"2-9D93E80306A7AA88802572580072717A",
          "@unid":"9D93E80306A7AA88802572580072717A",
          "@noteid":"19376",
          "@position":"2",
          "@read":true,
          "@siblings":40000,
          "@form":"Person",
          "$17":"Aaron, Dave",
          "InternetAddress":"gratia@incito.co.uk",
          "OfficeCountry":"Brazil"
      },
      {
          "@entryid":"3-FAFA753960DB587A80257258007287CF",
          "@unid":"FAFA753960DB587A80257258007287CF",
          "@noteid":"1D842",
          "@position":"3",
          "@read":true,
          "@siblings":40000,
          "@form":"Person",
          "$17":"Aaron, Donnie",
          "InternetAddress":"vociferor@nequities.net",
          "OfficeCountry":"Algeria"
      }
]

So far I make it work using:

  {name:'OfficeCountry',
               width:200,                                      
               formatter:'showlink',
               formatoptions:{ baseLinkUrl:'xPerson.xsp',addParam: '&action=openDocument', idName:'documentId'}
    }

but I need to open it in a new window

I also tried with formatter:editLinkFmatter

function editLinkFmatter(cellvalue, options, rowObject) {
    return "<a href='./" + rowObject[2] + "' class='requestlink'>" + cellvalue + "</a>";
    //return "<a href='./documentId=" + rowObject.@unid + "' >Click here</a>";
    //return "<a href='./documentId=" + options.idName + "&action=OpenDocument'>" + cellvalue + "</a>";
}

and I can't use rowObject.@unid because the node name

BenMorel
  • 34,448
  • 50
  • 182
  • 322
PSolano
  • 398
  • 5
  • 21

1 Answers1

3

It seems to me that you should just use target="_blank"attribute in the <a> (see here and here). The standard 'showlink' formatter supports target attribute.

As the alternative to the custom formatter you can use 'dynamicLink' formatter (see the answer). You can download the last version of jQuery.jqGrid.dynamicLink.js from here.

UPDATED: To assess the property with the name @unid you can use syntax rowObject["@unid"]. So the editLinkFmatter can be like

function editLinkFmatter(cellvalue, options, rowObject) {
    return "<a href='?documentId=" + rowObject["@unid"] +
        "&action=OpenDocument' class='requestlink'>" + cellvalue + "</a>";
}

or better like

function editLinkFmatter(cellvalue, options, rowObject) {
    return "<a href='?" +
        $.param({
            documentId: rowObject["@unid"],
            action: 'OpenDocument'
        }) + "' class='requestlink'>" + cellvalue + "</a>";
}
Community
  • 1
  • 1
Oleg
  • 220,925
  • 34
  • 403
  • 798
  • Thank @Oleg, I'm clear with _blank attribute; the problem is I can't get the row value for @unid item. I tried rowObject.@unid and I get "can't convert AttributeName to string" because the @ on my item name; if I try for example rowObject.InternetAddress works fine. I also tried rowObject[2] with no joy that is why I'm using `{name:'OfficeCountry', width:200, formatter:'showlink', formatoptions:{ baseLinkUrl:'xPerson.xsp',addParam: '&action=openDocument', idName:'documentId'} } ` and works fine but not opening in a new window – PSolano Mar 28 '12 at 19:32
  • @PSolano: Ohh! It's not a real problem. You can just use another syntax: `rowObject["@unid"]`. You can use this it the property has some special characters, like '@' or ' ' (space) for example: `rowObject["my property with spaces"]`. – Oleg Mar 28 '12 at 19:52
  • You are the men definitely. Worked like a charm. I'm a Notes Developer and I want to use this grid control on Domino applications and I haven't seen anything outside integrating jqGrid and Notes. Still have lot of questions and I'm moving slowly but with good progress. Tks again. – PSolano Mar 28 '12 at 20:45
  • @PSolano: You are welcome! I never developed for Domino (only a little for Exchange), but I know that it allows many kind of customization. If you'll become more questions I'll try to help you. Best wishes! – Oleg Mar 28 '12 at 21:10
  • Thanks; I'll post some questions today if you have some time to take a look.Thanks in advance – PSolano Mar 29 '12 at 08:21