2017-06-01 7 views
1

からエクスポートする私のページでjQgridを使用しています。グリッドに表示されているデータをpdfにエクスポートしてExcelにエクスポートする必要があります。ボタンを作成してコードを追加しましたjQgridのデータをjqueryコード

jQuery("#btnExportPdf").on("click", function(){ 
       jQuery("#jqGrid").jqGrid("exportToPdf",{ 
        title: 'Export to PDF', 
        orientation: 'portrait', 
        pageSize: 'A4', 
        description: 'Meeting Details', 
        customSettings: null, 
        download: 'download', 
        includeLabels : true, 
        includeGroupHeader : true, 
        includeFooter: true, 
        fileName : "Meetings.pdf" 
       }) 
      }) 

他に何が必要ですか?

答えて

1

はexportGrid()関数が呼び出されるところから、この機能

function exportGrid() { 
     mya = $("#" + table).getDataIDs(); // Get All IDs 
     var data = $("#" + table).getRowData(mya[0]); // Get First row to get the 
     // labels 
     var colNames = new Array(); 
     var ii = 0; 
     for (var i in data) { 
      colNames[ii++] = i; 
     } // capture col names 

     var html = "<html><head>" 
     + "<style script=&quot;css/text&quot;>" 
     + "table.tableList_1 th {border:1px solid black; text-align:center; " 
     + "vertical-align: middle; padding:5px;}" 
     + "table.tableList_1 td {border:1px solid black; text-align: left; vertical-align: top; padding:5px;}" 
     + "</style>" 
     + "</head>" 
     + "<body style=&quot;page:land;&quot;>"; 


     for (var k = 0; k < colNames.length; k++) { 
      html = html + "<th>" + colNames[k] + "</th>"; 
     } 
     html = html + "</tr>"; // Output header with end of line 
     for (i = 0; i < mya.length; i++) { 
      html = html + "<tr>"; 
      data = $("#" + table).getRowData(mya[i]); // get each row 
      for (var j = 0; j < colNames.length; j++) { 
       html = html + "<td>" + data[colNames[j]] + "</td>"; // output each Row as 
       // tab delimited 
      } 
      html = html + "</tr>"; // output each row with end of line 
     } 
     html = html + "</table></body></html>"; // end of line at the end 
     alert(html); 
     html = html.replace(/'/g, '&apos;'); 
    } 

Reference

+0

を使用してみてください? –

+0

clickイベントの内側@AA – Manoj

+0

私の最後にマーキングのためのリンクが表示されていないため、これは@DipenShah – Manoj

関連する問題