- Home
- Forum
- React - EJ 2
- GridComponent error when calling groupModule.expandAll() on an empty datasource
GridComponent error when calling groupModule.expandAll() on an empty datasource
We're currently encountering an issue on the React GridComponent configured with groupSettings. Whenever the component receives an empty dataSource and groupModule.expandAll(). We found this issue while migrating from 27.1.50 to 30.2.4.
Below is a snapshot of our configuration:
const applyGroupExpandCollapse = () => { if (gridRef.current?.groupModule) { if (expandAllGroups) { gridRef?.current?.groupModule.expandAll(); } else { gridRef?.current?.groupModule.collapseAll(); } } }; <GridComponentref={gridRef}height="100%"dataSource={filteredData}pageSettings={{ pageSize:100}}allowPaging={true}allowGrouping={true}allowSorting={true}allowFiltering={true}allowReordering={true}allowResizing={true}showColumnChooser={true}rowSelected={handleRowSelect}rowDeselected={handleRowDeselect}allowTextWrap={true}textWrapSettings={{ wrapMode:'Content' }}groupSettings={{ columns: ['typeCode'], showDropArea: false, captionTemplate: groupCaptionTemplate, disablePageWiseAggregates: true, }}filterSettings={{ type:'Menu' }}selectionSettings={{ type:'Multiple', persistSelection: true }} ><ColumnDirectivefield="typeCode"textAlign="Left"width="180"visible={false}showInColumnChooser={false}headerText='Problem Type' /></ColumnsDirective><Injectservices={[Group,Sort, Filter, Page, Toolbar, Selection, Resize, Reorder, ColumnChooser]} /></GridComponent>
Below is the error that we get:
Cannot read properties of undefined (reading 'isCaptionRow')
TypeError: Cannot read properties of undefined (reading 'isCaptionRow')
at Group2.expandCollapse (/node_modules/.vite/deps/chunk-S2KSHGQF.js?v=91d263b7:32963:49)
at Group2.collapseAll (node_modules/.vite/deps/chunk-S2KSHGQF.js?v=91d263b7:32975:12)
at applyGroupExpandCollapse (Screen.tsx?t=1766100568364:122:39)
at GridComponent2.onActionComplete (Screen.tsx?t=1766100568364:100:5)
at Observer2.notify (node_modules/.vite/deps/chunk-P3FVOJFM.js?v=91d263b7:1609:23)
We have confirmed that the reported behavior is an issue from our side and logged it as “Script Error When Calling expandAll or collapseAll on Grouped Columns with Empty DataSource”. Thank you for taking the time to report this issue and helping us improve our product. At Syncfusion, we are committed to fixing all validated defects (subject to technical feasibility and Product Development Life Cycle ) and will include the defect fix in our upcoming patch release which will be rolled out on “January 06, 2026”. Until then we appreciate your patience.
You can now track the current status of your request, review the proposed resolution timeline, and contact us for any further inquiries through the below link,
Temporary Sample-Level Solution :
To avoid the error until the official fix is released, please add a condition to check whether the grid has data before calling expandAll() or collapseAll(). Here’s the updated sample code:
Code Example : const applyGroupExpandCollapse = () => { if ( gridRef.current?.groupModule && gridRef.current?.currentViewData.length ) { if (expandAllGroups) { gridRef?.current?.groupModule.expandAll(); } else { gridRef?.current?.groupModule.collapseAll(); } } }; |
Disclaimer: "Inclusion of this solution in the weekly release may change due to other factors including but not limited to QA checks and works reprioritization".
We are glad to announce that, we have included the fix for the issue “Script Error When Calling expandAll or collapseAll on Grouped Columns with Empty DataSource” in our 32.1.22 release. So please upgrade to our latest version of the Syncfusion package to resolve the reported issue.
Root Cause: When the column is grouped initially, the groupExpandCollapse method is invoked. Since the grid has no rows, empty row data is passed, causing rowObj to become undefined, which leads to the script error.
Solution: Modify the if condition in the expandCollapse method to return immediately when the row object is empty. This prevents script errors when expandAll or collapseAll is called.
Sample: https://stackblitz.com/edit/react-9inqcwlu-7w5dqkyj?file=index.js
We thank you for your support and appreciate your patience in waiting for this release. Please get back to us if you need any further assistance.
- 3 Replies
- 2 Participants
-
RA Roberto Añonuevo
- Dec 19, 2025 06:02 AM UTC
- Jan 6, 2026 10:58 AM UTC