Author Topic: exporting of nested grid  (Read 3112 times)

saritha

  • Newbie
  • *
  • Posts: 16
    • View Profile
exporting of nested grid
« on: April 03, 2019, 08:00:37 pm »
how to export nested grid in excel format .

Hatmaker

  • Newbie
  • *
  • Posts: 1
    • View Profile
Re: exporting of nested grid
« Reply #1 on: April 19, 2019, 04:45:33 pm »
Can you even export a nested grid directly into Excel?

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: exporting of nested grid
« Reply #2 on: April 21, 2019, 04:07:34 pm »
Only single grid ( main or nested ) can be exported at a time into Excel

tarunsharma

  • Newbie
  • *
  • Posts: 20
    • View Profile
Re: exporting of nested grid
« Reply #3 on: November 17, 2020, 11:05:13 pm »
I am trying to export both parent and nested gird all together in one excel sheet, but the problem is it show few nested rows as blank even though they do have the values. The reason is when parent grid send the request to retrieve nested rows it will take time and before get the response back it will check next parent row. Can anyone suggest me any solution? I am doing something like this.

function exportSlow() {

            var grid = this,
                w = grid.exportExcel({ workbook: true, render: true }),
                wrows = w.sheets[0].rows,
                rows = [],
                i = 0,
                loading = grid.option('strLoading'),
                pdata = grid.pageData();

            grid.showLoading();

            rows.push(wrows[0]);//parent header row.

            var id = setInterval(function () {
                var rd = pdata;
                if (rd) {
                    rows.push(wrows[i + 1]);//parent data row.                               
                    var $detail = getDetail(grid, rd),
                        w2 = $detail.pqGrid('instance').exportExcel({
                            workbook: true,
                            render: true
                        });

                    w2.sheets[0].rows.forEach(function (rd2) {
                        //shift all cells to the right.
                        rd2.cells.forEach(function (cell) {
                            if (cell.indx != null)
                                cell.indx++;
                        })
                        //and add empty cell at beginning of every row.
                        rd2.cells.unshift({});
                        rows.push(rd2)
                    })

                    rows.push({})//empty row.
                    i++;
                    grid.option('strLoading', Math.round(i * 100 / pdata.length) + "%")
                }
                else {
                    clearInterval(id);
                    w.sheets[0].rows = rows;
                    var blob = pq.excel.exportWb({ workbook: w, type: 'blob' });//export 1st workbook into Excel file.
                    saveAs(blob, "pqGrid.xlsx");
                    grid.hideLoading();
                    grid.option('strLoading', loading);
                }
            });
        }