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);
}
});
}