How to enable jQgrid to Export data into PDF/Excel

后端 未结 4 582
生来不讨喜
生来不讨喜 2020-12-06 06:19

I am new in jQuery/jQgrid coding. I am using jQgrid version is 4.4.4 & jQuery 1.8.3. I want to enable export to PDF/EXCEL functionality in my jQgrid. For that I referred

4条回答
  •  北荒
    北荒 (楼主)
    2020-12-06 06:39

    function to be called inside of your onclick event.

    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 = ""
            + ""
            + ""
            + "";
    
    
    for ( var k = 0; k < colNames.length; k++) {
        html = html + "" + colNames[k] + "";
    }
    html = html + ""; // Output header with end of line
    for (i = 0; i < mya.length; i++) {
        html = html + "";
        data = $("#" + table).getRowData(mya[i]); // get each row
        for ( var j = 0; j < colNames.length; j++) {
         html = html + "" + data[colNames[j]] + ""; // output each Row as
                    // tab delimited
        }
        html = html + ""; // output each row with end of line
    }
    html = html + ""; // end of line at the end
    alert(html);
    html = html.replace(/'/g, ''');
    //  var form = "
    "; // form = form + ""; // form = form + "
提交回复
热议问题