How to enable jQgrid to Export data into PDF/Excel

后端 未结 4 578
生来不讨喜
生来不讨喜 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:42

    Here is a clever solution to save the jqGrid data as excel sheet: (You just need to call this function with GridID and an optional Filename)

    var createExcelFromGrid = function(gridID,filename) {
        var grid = $('#' + gridID);
        var rowIDList = grid.getDataIDs();
        var row = grid.getRowData(rowIDList[0]); 
        var colNames = [];
        var i = 0;
        for(var cName in row) {
            colNames[i++] = cName; // Capture Column Names
        }
        var html = "";
        for(var j=0;j

    We first create a CSV string delimited with ;. Then an anchor tag is created with certain attributes. Finally click is called on a to download the file.

提交回复
热议问题