2012-03-28 14 views
1

このjqgridの定義があり、選択したドキュメントを新しいウィンドウで開こうとしています。jQgridへのリンクを追加して新しいウィンドウで開く

私の最終的なURLは、これらが好き必要があります。

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

とも私はこのタイプの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}); 

私のJSONオブジェクトは、次のようになりますと、私が使用していないよ注意してくださいdocumentId私は私のColModelの一部として私のURLに必要です。私が必要とする値は、これまでのところ

 [ 
     { 
      "@entryid":"1-B933790B1DC265ED8025725800728CC5", 
      "@unid":"B933790B1DC265ED8025725800728CC5", 
      "@noteid":"1E76E", 
      "@position":"1", 
      "@read":true, 
      "@siblings":40000, 
      "@form":"Person", 
      "$17":"Aaron, Adam", 
      "InternetAddress":"[email protected]", 
      "OfficeCountry":"Namibia" 
     }, 
     { 
      "@entryid":"2-9D93E80306A7AA88802572580072717A", 
      "@unid":"9D93E80306A7AA88802572580072717A", 
      "@noteid":"19376", 
      "@position":"2", 
      "@read":true, 
      "@siblings":40000, 
      "@form":"Person", 
      "$17":"Aaron, Dave", 
      "InternetAddress":"[email protected]", 
      "OfficeCountry":"Brazil" 
     }, 
     { 
      "@entryid":"3-FAFA753960DB587A80257258007287CF", 
      "@unid":"FAFA753960DB587A80257258007287CF", 
      "@noteid":"1D842", 
      "@position":"3", 
      "@read":true, 
      "@siblings":40000, 
      "@form":"Person", 
      "$17":"Aaron, Donnie", 
      "InternetAddress":"[email protected]", 
      "OfficeCountry":"Algeria" 
     } 
] 

を@unidされ、私はそれを使用して動作させる:

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

が、私は

私もフォーマッタにしようとした新しいウィンドウで開く必要があります。editLinkFmatter

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

と私はrowObjectを使用することはできません。@ UNIDノード名

理由

答えて

3

herehereを参照)にはtarget="_blank"という属性を使用してください。標準の 'showlink'フォーマッタはtarget属性をサポートしています。

カスタムフォーマッタの代わりに、 'dynamicLink'フォーマッタ(the answerを参照)を使用できます。 jQuery.jqGrid.dynamicLink.jsの最新バージョンはhereからダウンロードできます。

更新済み@unidという名前のプロパティを評価するには、構文rowObject["@unid"]を使用できます。だから、editLinkFmatter私は_blank属性を持つ明確なよ、@Olegありがとう

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

よう

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

以上のようにすることができます。問題は、@ unid項目の行の値を取得できないことです。私はrowObject。@ unidを試してみました。なぜなら、@ itemNameのためにAttributeNameを文字列に変換できません。たとえば、私がしようとすると、rowObject.InternetAddressは正常に動作します。私は '{name: 'OfficeCountry'、width:200、formatter: 'showlink'、formatoptions:{baseLinkUrl: 'xPerson.xsp'、addParam: '&action}を使用しているので、rowObject [2] = openDocument '、idName:' documentId '}} 'とうまく動作しますが、新しいウィンドウで開きません。 – PSolano

+0

@ PSolano:Ohh!それは本当の問題ではありません。 'rowObject [" @ unid "]'という別の構文を使うことができます。これを使用すると、プロパティに '@ 'や' '(スペース)のような特殊文字がいくつかあります:' rowObject ["my properties with spaces"] '。 – Oleg

+0

あなたは間違いなく男性です。魅力のように働いた。私はNotes Developerです。このグリッドコントロールをDominoアプリケーションで使用したいのですが、jqGridとNotesを統合した外部は見たことがありません。まだ多くの質問があり、私はゆっくりと進みますが、良い進歩があります。再びTks。 – PSolano

関連する問題