jQWidgets Forums

jQuery UI Widgets Forums Grid Error in PDF export in jqxGrid

This topic contains 2 replies, has 2 voices, and was last updated by  Hristo 6 years, 11 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • Error in PDF export in jqxGrid #100765

    Abbas
    Participant

    We are trying to export jqxGrid data into pdf .I am converting date and merge firstname and last name into a single column like name its working fine in ui but having issue while export to pdf below is minimum required code. please help menull

    var source = {
    datatype: “json”,
    url: settings.urls.GetCustomers,
    beforeprocessing: function (data) {
    source.totalrecords = data.TotalRows;
    }
    };

    var dataAdapter = new $.jqx.dataAdapter(source,
    {
    formatData: function (data) {
    $.extend(data, {
    sId: settings.sId,
    searchTerm: null,
    });
    return data;
    }
    }
    );

    $(“#tableContainer”).jqxGrid({
    width: ‘100%’,
    source: dataAdapter,
    pagesize: gridPageSize,
    pagesizeoptions: arrayPageSize,
    autoheight: true,
    pageable: true,
    virtualmode: true,
    rendergridrows: function (obj) {
    var days = [“Sun”, “Mon”, “Tue”, “Wed”, “Thu”, “Fri”, “Sat”];
    if (obj.data.length > 0) {
    obj.data = Object.values(obj.data);
    $.each(obj.data, function (index, item) {
    debugger;
    //obj.data[index].Firstname = (item.Lastname != null ? item.Lastname : ” “) + “,” + (item.Firstname != null ? item.Firstname : ” “);
    obj.data[index].Firstname = (item.Firstname != null ? item.Firstname : ” “) + “,” + (item.Lastname != null ? item.Lastname : ” “) ;
    if (item.StartDate) {
    var startDate = new Date(parseInt(item.StartDate.substr(6)));
    obj.data[index].StartDate = days[startDate.getDay()] + ” ” + startDate.toStringFormat(“dd MMM yyyy HH:mm”);
    }
    if (item.EndDate) {
    var endDate = new Date(parseInt(item.EndDate.substr(6)));
    obj.data[index].EndDate = days[endDate.getDay()] + ” ” + endDate.toStringFormat(“dd MMM yyyy HH:mm”);
    }

    obj.data[index].Address1 = (item.Address1 != null ? item.Address1 : ” “) + ” ” + (item.Address2 != null ? item.Address2 : ” “) + ” ” + (item.City != null ? item.City : ” “) + ” ” + (item.State != null ? item.State : ” “) + ” ” + (item.PostCode != null ? item.PostCode : ” “) + ” ” + (item.CountryIsoCode != null ? item.CountryIsoCode : ” “);
    var action = “<td class=’action-column’> ” + (obj.data.enchanceInventoryandPricing === true ?
    (““) :
    (““)) + “</td>”
    obj.data[index].Action = action;

    });
    }
    return obj.data;
    },
    columns: [
    { text: ‘Customer’, datafield: ‘Firstname’},
    { text: ‘Address’, datafield: ‘Address1’},
    { text: ‘Email ‘, datafield: ‘Email’},
    { text: ‘Last Stay’, datafield: ‘StartDate’},
    { text: ‘Next/Current Stay’, datafield: ‘EndDate’},
    { text: ‘Owes’, datafield: ‘Owes’},
    { text: ‘Actions’, datafield: ‘Action’}
    ]
    });

    Code PDF Export

    $(“#pdfExport”).click(function () {
    $(‘#tableContainer’).jqxGrid(‘hidecolumn’, ‘Action’);
    $(“#tableContainer”).jqxGrid(‘exportdata’, ‘pdf’, ‘CustomerjqxGrid’);
    $(‘#tableContainer’).jqxGrid(‘showcolumn’, ‘Action’);
    });

    Error in PDF export in jqxGrid #100766

    Abbas
    Participant

    $(“#pdfExport”).click(function () {
    $(‘#tableContainer’).jqxGrid(‘hidecolumn’, ‘Action’);
    $(“#tableContainer”).jqxGrid(‘exportdata’, ‘pdf’, ‘CustomerjqxGrid’);
    $(‘#tableContainer’).jqxGrid(‘showcolumn’, ‘Action’);
    });

    Error in PDF export in jqxGrid #100790

    Hristo
    Participant

    Hello Abbas,

    It happens too fast.
    I would like to suggest you look at this example.

    Best Regards,
    Hristo Hristov

    jQWidgets team
    http://www.jqwidgets.com

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.