excelQueryCellInfo only works intermittently with a hierarchical grid

I have 3 grids (parent, child, and grandchild) and if the amount of data is small (~12 rows in grandchild, 1 row in child, 1 row in parent,) then excelQueryCellInfo works as intended to change the background color of certain cells in the grandchild grid. However, if the grids are larger (2 rows in the parent grid each with ~10 children, each child row having ~12 grandchild rows,) the cells are not formatted. I have added simple console.log statements, and it appears that when the grids are larger the excelQueryCellInfo event is never triggered. I have tried  


I have pasted the grid definitions, the function assigned to the excel download button, and the function assigned to excelQueryCellInfo below:

var grandChildColumns = [];
grandChildColumns[0] = { field: data.itemRowFields[1], headerText: data.itemRowHeaders[1], width: "130", allowEditing: false };
grandChildColumns[1] = { field: data.itemRowFields[2], headerText: data.itemRowHeaders[2], width: "100", allowEditing: true };
grandChildColumns[2] = { field: "Weeks.0", headerText: data.itemRowHeaders[3], width: "100", allowEditing: false };
grandChildColumns[3] = { field: "Weeks.1", headerText: data.itemRowHeaders[4], width: "100", allowEditing: false };
for (let i = 5; i < ccc; i++) {
    let fname = "Weeks." + (i - 3);
    grandChildColumns[i - 1] = {
        field: fname,
        headerText: data.itemRowHeaders[i],
        width: "100",
        EditType: "numericedit",
    };
}






var grandChildGrid = new ej.grids.Grid({
    dataSource: data.itemRows,
    queryString: "itemLoc",
    columns: grandChildColumns,
    queryCellInfo: onGrandChildGridQueryCellInfo,
    excelQueryCellInfo: exportQueryCellInfo,
    frozenColumns: 1,
    editSettings: { allowEditing: true, mode: 'Batch' },
    allowExcelExport: true,
    cellSaved: breakOnMe,
    //beforeExcelExport: beforeExcelExport,
});




var childGrid = new ej.grids.Grid({
    dataSource: data.itemDetails,
    queryString: "LocationId",
    columns: [
        { field: data.itemFields[0], headerText: data.itemHeaders[0], width: "0", isPrimaryKey: true },
        { field: data.itemFields[1], headerText: data.itemHeaders[1], width: "120" },
        { field: data.itemFields[2], headerText: data.itemHeaders[2], width: "120" },
        { field: data.itemFields[3], headerText: data.itemHeaders[3], width: "120" },
        { field: data.itemFields[4], headerText: data.itemHeaders[4], width: "120" },
    ],
    childGrid: grandChildGrid,
    allowPdfExport: true,
    allowExcelExport: true,
    excelQueryCellInfo: exportQueryCellInfo,
    beforeExcelExport: beforeExcelExport,
    //dataBound: dbb,
});


parentGrid = new ej.grids.Grid({
    dataSource: data.locationDetails,
    columns: [
        { field: data.locFields[0], headerText: data.locHeaders[0], width: "125", isPrimaryKey: true, textAlign: "Right" },
        { field: data.locFields[1], headerText: data.locHeaders[1], width: "225" },
    ],
    allowSorting: true,
    childGrid: childGrid,
    allowPdfExport: true,
    allowExcelExport: true,
    detailDataBound: breakOnMe,
    dataBound: dbb,
    excelQueryCellInfo: exportQueryCellInfo,
});


$("#btn_export").on("click.tmg", async function (e) { //Export grid to Excel
    await showLoadingModal();
    cellCount = 0;
    try {
        var gridObj = document.getElementById("Locations").ej2_instances[0];
        var excelExportProperties = { hierarchyExportMode: "All" };
        gridObj.excelExport(excelExportProperties);
    } finally {
        await hideLoadingModal();
    }
});


function exportQueryCellInfo(args) {
    let msg = ""
    try {
        const keys = Object.keys(args);
        msg = keys;
    }
    catch (err) {
        msg = err;
    }
    finally {
        cellCount = cellCount + 1
        console.log("Cell " + cellCount + ": " + msg);
    }


    // try {
    // if (Object.hasOwn(args, 'data') == false) throw "no args.data property";
    // if (Object.hasOwn(args.data, 'Name') == false) throw "no args.data.Name property";
    // if (!(args.data.Name === "Balance" || args.data.Name === "Weeks On Hand")) throw ("wrong row ; " + args.data.Name) ;
    // if (Object.hasOwn(args, 'column') == false) throw "no args.column property";
    // if (Object.hasOwn(args.column, 'index') == false) throw "no args.column.index property";
    // if (args.column.index <= 3) throw "too soon";
    // if (isNaN(args.value)) throw "not a number";
    // if (Number(args.value) > 0) throw "too much";
    // args.style = { backColor: "#ff0101" };
    // console.log(args.data.Name + ", " + args.column.index + ", " + args.value)
    // }
    // catch (err) {
    // console.log("Cell " + cellCount + ": " + err);
    // }
    // finally {
    // //console.log("exportQueryCellInfo done")
    // cellCount = cellCount + 1;
    // }
    // if (args.data.Name === "Balance" || args.data.Name === "Weeks On Hand") {
    // // Change the background color of cells in other columns based on their value
    // if (args.column.index > 3) {
    // if (Number(args.value) <= 0) {
    // args.style = { backColor: "#ff0101" }
    // }
    // }
    // }
}

1 Reply

NP Naveen Palanivel Syncfusion Team January 16, 2024 02:21 PM UTC

Hi Electa Baker,

Based on your query, It seems that the excelQueryCellInfo event fails to trigger when dealing with larger data in grids. We have created a sample and validated it on our end. However, the reported problem does not occur on our side. Please refer  the sample for your reference.

If the reported issue still reproduced then kindly share the below details to validate further at our end.


  1. Please share if we missed any replication procedure in attached sample
  2. Could you please ensure that , reported issue still occurs in latest version(24.1.45)
  3. Share a video demonstration of the issue with a detailed explanation. This will greatly assist us in understanding the problem.
  4. Please provide a simple sample that reproduces the issue with duplicate data or try to modify the above mentioned sample.


The above-requested details will be very helpful for us to validate the reported query at our end and provide the solution as early as possible.


Regards,

Naveen Palanivel



Attachment: 503682.Net6sample_800ce8a0.zip

Loader.
Up arrow icon