Click here to Skip to main content
14,545,210 members
Rate this:
Please Sign up or sign in to vote.
See more:
How can I use jqxGrid / iTextSharp export to PDF ?
I get data by 'json'.
How can ('jqxGridResult') export to PDF using iTextSharp?

What I have tried:

function GetTestReportResult()
  type: "POST",   
    url: "wsMethodDbData.asmx/getData", 
   contentType: "application/json; charset=utf-8",
   data: "{}",
   dataType: "json",
   success: OnSuccess,
   error: function (type) 
     $("#errMsg").text("ERROR!!" + type.responseText);
  function OnSuccess(response)
       var items;                    
       items = response.d;
       if(items.length == 0)
         $("#errMsg").text("No Data");

function GenerateGrid(data)
     var source =
        datatype: "json",
        datafields: [
        localdata: data

     var localdataAdapter = new $.jqx.dataAdapter(source);

        width: '99%',
        height: '400px',
        autoheight: true,
        source: localdataAdapter,
        pageable: false,
        autoheight: false,
        sortable: false,
        altrows: false,
        enabletooltips: false,
        editable: false,
        autorowheight: false,
        showgroupaggregates: false,
        showaggregates: false,
        groupable: false,
        showstatusbar: false,
        sortable: true,
        showfilterrow: false,
        filterable: true,
        selectionmode: 'multiplecellsextended',
                text: '#', align: 'center', sortable: false, filterable: false, editable: false, groupable: false, draggable: false, resizable: false, datafield: null, columntype: 'number', width: 60,
                cellsrenderer: function (row, column, value)
                      return "<div style='margin:4px;'>" + (value + 1) + "</div>";
        theme: 'fresh'
Updated 21-May-20 22:39pm

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

I think you're going to have to write a method to export your JSON data as a PDF Table - this may be a start point jQGrid PDF Export[^] ... this might also be useful json - JQGgrid- Comment générer un fichier pdf/excel à partir des données de la grille[^]
ChrisKWHsu 24-May-20 22:43pm
thanks Garth.
My development Tool is VS2003, without MVC.
How can I export "$("#jqxGridResult").jqxGrid" to PDF ??
Garth J Lancaster 25-May-20 0:57am
What - you want me to write it for you ? .. er, no - 1) if you're a student then you have to assume you lecturers are watching, and we wouldnt be doing you any favour by cheating for you, or 'the industry' a favour if you had to work with one of us in the future 2) if you're being paid to do this then you're in a better position than many, myself included, having been 'hibernated' thanks to Covid-19 ...

- looking at the first link I supplied, there was this

private static void ExportPDF<TSource>(IList<TSource> customerList,string[] columns, string filePath)
    Font headerFont = FontFactory.GetFont("Verdana", 10, Color.WHITE);
    Font rowfont = FontFactory.GetFont("Verdana", 10, Color.BLUE);
    Document document = new Document(PageSize.A4);
    PdfWriter writer = PdfWriter.GetInstance(document, 
               new FileStream(filePath, FileMode.OpenOrCreate));
    PdfPTable table = new PdfPTable(columns.Length);
    foreach (var column in columns)
        PdfPCell cell = new PdfPCell(new Phrase(column, headerFont));
        cell.BackgroundColor = Color.BLACK;
    foreach (var item in customerList)
        foreach (var column in columns)
            string value = item.GetType().GetProperty(column).GetValue(item).ToString();
            PdfPCell cell5 = new PdfPCell(new Phrase(value, rowfont));

that's a good start
ChrisKWHsu 25-May-20 1:51am
Sorry, Garth.
you dont need to write it for me. I just ask the advise of experts.
I really appreciate your willingness to respond to my inquiries.
Sorry for the misunderstanding.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100