Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
230
how to export the date in proper format in infragistics hierarchical grid
posted

Hi Team,

In normal grid, we had one of the columns as DATE which was not getting exported properly. We were getting NaN in excel sheet. But the issue is fixed now.

Following/Highlighted code we modified to get it proper in excel sheet.

 

var exportingIndicator = $('<div>');

    $('#exportButton').on('click', function () {

      //  $("#loaderModal").modal('show');

        var gridExcelExporter = new $.ig.GridExcelExporter();

        var $grid = $('#csagrid');

        gridExcelExporter.exportGrid($grid, {

            fileName: "CSAReport",

            gridStyling: "applied"

          

        }, {

                exportStarting: function (e, args) {

                    

                    showExportingIndicator(args.grid, exportingIndicator);

                },

                cellExported: function (e, args) {

                    if (args.xlRow.index() == 0) {

                        return;

                    }

                    if (args.columnIndex == 2) {    // columnIndex 2 because date column is at index 2

                        var rowIndexValue = e._xlRowIndex - 1;

                        var colCellValue = e._dataSource._data[rowIndexValue].ENTRY_DATE;

                        var val = formatDate(colCellValue);

                        args.xlRow.setCellValue(args.columnIndex, val);

                    }

                },

                success: function () {

              //      $("#loaderModal").modal('hide');

                    hideExportingIndicator(exportingIndicator);

                },

            });

    });

 

----------------------------------------------------------------------------------------

And this function –

function formatDate(date) {

    var d = new Date(parseInt((date).match(/\d+/)[0]));

    month = '' + (d.getMonth() + 1),

        day = '' + d.getDate(),

        year = d.getFullYear();

 

    if (month.length < 2) month = '0' + month;

    if (day.length < 2) day = '0' + day;

 

    return [month, day, year].join('/');

}

 

----------------------------------------------------------------------------------------------------------------------------------------

 

But, we are not able to get the same DATE column when it is a hierarchical grid.

 

ENTRY_DATE column is in the child grid. How do we modify our existing code(code for getting date in proper format after exporting to excel) for  hierarchical grid?