@visns-studio/visns-components 5.9.3 → 5.9.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -86,7 +86,7 @@
|
|
|
86
86
|
"react-dom": "^17.0.0 || ^18.0.0"
|
|
87
87
|
},
|
|
88
88
|
"name": "@visns-studio/visns-components",
|
|
89
|
-
"version": "5.9.
|
|
89
|
+
"version": "5.9.4",
|
|
90
90
|
"description": "Various packages to assist in the development of our Custom Applications.",
|
|
91
91
|
"main": "src/index.js",
|
|
92
92
|
"files": [
|
|
@@ -587,6 +587,17 @@ const DataGrid = forwardRef(
|
|
|
587
587
|
/** Group expansion state */
|
|
588
588
|
const [collapsedGroups, setCollapsedGroups] = useState({});
|
|
589
589
|
|
|
590
|
+
/** Track if groups have been initialized to prevent re-initialization */
|
|
591
|
+
const groupsInitializedRef = useRef(false);
|
|
592
|
+
|
|
593
|
+
// Reset initialization flag and clear state when groupBy changes
|
|
594
|
+
useEffect(() => {
|
|
595
|
+
if (ajaxSetting?.groupBy) {
|
|
596
|
+
groupsInitializedRef.current = false;
|
|
597
|
+
setCollapsedGroups({}); // Clear existing state when groupBy changes
|
|
598
|
+
}
|
|
599
|
+
}, [ajaxSetting?.groupBy]);
|
|
600
|
+
|
|
590
601
|
/** Force re-render trigger for group header consistency */
|
|
591
602
|
const [groupRenderKey, setGroupRenderKey] = useState(0);
|
|
592
603
|
|
|
@@ -670,6 +681,21 @@ const DataGrid = forwardRef(
|
|
|
670
681
|
.toString()
|
|
671
682
|
.localeCompare(bValue.toString());
|
|
672
683
|
});
|
|
684
|
+
|
|
685
|
+
// Initialize all groups as collapsed when data is first loaded
|
|
686
|
+
if (!groupsInitializedRef.current && res.data.length > 0) {
|
|
687
|
+
const uniqueGroups = [...new Set(res.data.map(row => row[groupField]))];
|
|
688
|
+
const initialCollapsedState = {};
|
|
689
|
+
uniqueGroups.forEach(groupValue => {
|
|
690
|
+
if (groupValue !== undefined && groupValue !== null) {
|
|
691
|
+
initialCollapsedState[groupValue] = true;
|
|
692
|
+
}
|
|
693
|
+
});
|
|
694
|
+
|
|
695
|
+
console.log('Initializing all groups as collapsed:', initialCollapsedState);
|
|
696
|
+
setCollapsedGroups(initialCollapsedState);
|
|
697
|
+
groupsInitializedRef.current = true;
|
|
698
|
+
}
|
|
673
699
|
}
|
|
674
700
|
|
|
675
701
|
if (setTotal) {
|