@@ -1029,7 +1029,6 @@ export const App = () => {
10291029 } ;
10301030
10311031 const checkboxCreated = ( id : string , checkboxReference : Record < string , CheckBoxComponent > ) => {
1032-
10331032 // For celltemplate checkbox - disable allowadding if initially checked
10341033 if ( id === 'celltemplate' ) {
10351034 if ( checkboxReference [ id ] && checkboxStates [ id ] ) {
@@ -1301,7 +1300,6 @@ export const App = () => {
13011300 dropdownReference [ id ] . enabled = isTimescaleEnabled ;
13021301 }
13031302 }
1304-
13051303 } ;
13061304
13071305 const timepickerCreated = ( id : string , timepickerReference : Record < string , TimePickerComponent > ) => {
@@ -1967,7 +1965,7 @@ export const App = () => {
19671965 if ( id === 'eventtemplate' || id === 'celltemplate' || id === 'headerrow' || id === 'headerrowstemplate' ) {
19681966 newValues [ 'enablegrouping' ] = false ;
19691967 }
1970-
1968+ tempCheckboxStates = newValues ;
19711969 return newValues ;
19721970 } ) ;
19731971 } ;
@@ -2183,7 +2181,7 @@ export const App = () => {
21832181 ]
21842182 }
21852183
2186- const [ datePickerValues , setDatePickerValues ] = useState < { [ key : string ] : string } > ( ( ) => {
2184+ let [ datePickerValues , setDatePickerValues ] = useState < { [ key : string ] : string } > ( ( ) => {
21872185 const initialValues : Record < string , string > = { } ;
21882186 // Initialize from checkbox configurations
21892187 Object . values ( checkboxConfigurations ) . forEach ( ( category ) => {
@@ -2217,7 +2215,7 @@ export const App = () => {
22172215 return initialValues ;
22182216 } ) ;
22192217
2220- const [ dropdownValues , setDropdownValues ] = useState < { [ key : string ] : string | number } > ( ( ) => {
2218+ let [ dropdownValues , setDropdownValues ] = useState < { [ key : string ] : string | number } > ( ( ) => {
22212219 const initialValues : Record < string , string | number > = { } ;
22222220
22232221 // Initialize from checkbox configurations
@@ -2239,7 +2237,7 @@ export const App = () => {
22392237 return initialValues ;
22402238 } ) ;
22412239
2242- const [ timePickerValues , setTimePickerValues ] = useState < { [ key : string ] : Date } > ( ( ) => {
2240+ let [ timePickerValues , setTimePickerValues ] = useState < { [ key : string ] : Date } > ( ( ) => {
22432241 const initialValues : Record < string , Date > = { } ;
22442242
22452243 // Initialize from checkbox configurations
@@ -2272,7 +2270,7 @@ export const App = () => {
22722270 type MultiSelectValue = number | string | boolean | object ; // Or number if you only use numbers
22732271 type MultiSelectState = Record < string , MultiSelectValue [ ] > ;
22742272
2275- const [ multiSelectValues , setMultiSelectValues ] = useState < MultiSelectState > ( ( ) => {
2273+ let [ multiSelectValues , setMultiSelectValues ] = useState < MultiSelectState > ( ( ) => {
22762274 const initialValues : MultiSelectState = { } ;
22772275
22782276 // Initialize with workDaysView for the 'workdays' field
@@ -2295,7 +2293,7 @@ export const App = () => {
22952293 return initialValues ;
22962294 } ) ;
22972295
2298- const [ numericTextboxValues , setNumericTextboxValues ] = useState < Record < string , number > > ( ( ) => {
2296+ let [ numericTextboxValues , setNumericTextboxValues ] = useState < Record < string , number > > ( ( ) => {
22992297 const initialValues : Record < string , number > = { } ;
23002298
23012299 // Add any other numeric textbox initial values from configurations
@@ -2314,7 +2312,43 @@ export const App = () => {
23142312 return initialValues ;
23152313 } ) ;
23162314
2317- const [ checkboxStates , setCheckboxStates ] = useState < Record < string , boolean > > ( ( ) => {
2315+ let [ checkboxStates , setCheckboxStates ] = useState < Record < string , boolean > > ( ( ) => {
2316+ const initialState : Record < string , boolean > = { } ;
2317+
2318+ Object . keys ( checkboxConfigurations ) . forEach ( ( category ) => {
2319+ const categoryItems = checkboxConfigurations [ category as keyof typeof checkboxConfigurations ] ;
2320+
2321+ categoryItems . forEach ( ( item ) => {
2322+ if ( 'groupField' in item ) {
2323+ // Item is a CheckboxGroup
2324+ const groupItems = ( item as CheckboxGroup ) . items ;
2325+
2326+ if ( Array . isArray ( groupItems ) ) {
2327+ groupItems . forEach ( ( checkbox ) => {
2328+ if ( 'defaultChecked' in checkbox ) {
2329+ initialState [ checkbox . id ] = checkbox . defaultChecked ?? false ;
2330+
2331+ // If enablegrouping is initially false, mark dependent controls as disabled
2332+ if ( ! initialState [ 'enablegrouping' ] ) {
2333+ initialState [ 'allowgroupedit_disabled' ] = true ;
2334+ initialState [ 'resourceheader_disabled' ] = true ;
2335+ initialState [ 'scrolltoresource_disabled' ] = true ;
2336+ initialState [ 'expandedfield_disabled' ] = true ;
2337+ }
2338+ }
2339+ } ) ;
2340+ }
2341+ } else if ( 'defaultChecked' in item ) {
2342+ // Item is a CheckboxConfig with defaultChecked property
2343+ initialState [ item . id ] = item . defaultChecked ?? false ;
2344+ }
2345+ } ) ;
2346+ } ) ;
2347+
2348+ return initialState ;
2349+ } ) ;
2350+
2351+ let [ tempCheckboxStates , setTempCheckboxStates ] = useState < Record < string , boolean > > ( ( ) => {
23182352 const initialState : Record < string , boolean > = { } ;
23192353
23202354 Object . keys ( checkboxConfigurations ) . forEach ( ( category ) => {
@@ -3351,6 +3385,7 @@ export const App = () => {
33513385 } ) ) ;
33523386 }
33533387 }
3388+ dropdownValues = newState ;
33543389 return newState ;
33553390 } ) ;
33563391 }
@@ -3418,6 +3453,7 @@ export const App = () => {
34183453 ...prev ,
34193454 [ fieldId ] : values
34203455 } ;
3456+ multiSelectValues = newState ;
34213457 return newState ;
34223458 } ) ;
34233459 }
@@ -3542,7 +3578,6 @@ export const App = () => {
35423578 body . classList . add ( prev [ 'themes' ] as string ) ;
35433579 theme . current = prev [ 'themes' ] as string ;
35443580 }
3545-
35463581 if ( prev [ 'localization' ] ) {
35473582 localization . current = prev [ 'localization' ] as string ;
35483583 setCulture ( prev [ 'localization' ] as string ) ;
@@ -3895,7 +3930,6 @@ export const App = () => {
38953930 Object . keys ( checkboxStates ) . forEach ( ( prop ) => {
38963931 checkboxStates [ prop ] = prev [ prop ] ;
38973932 } ) ;
3898-
38993933 return { ...prev } ;
39003934 } ) ;
39013935
@@ -4026,6 +4060,7 @@ export const App = () => {
40264060 ...prevState ,
40274061 ...( value && { [ timepickerId ] : value } ) // Only add the key if value is not null
40284062 } ;
4063+ timePickerValues = newState ;
40294064 return newState ;
40304065 } ) ;
40314066 }
@@ -4056,15 +4091,20 @@ export const App = () => {
40564091 newState . minDatePicker = value ;
40574092 }
40584093 }
4094+ datePickerValues = newState ;
40594095 return newState ;
40604096 } ) ;
40614097 }
40624098
40634099 const onNumericTextboxChange = ( numericTextboxId : string , value : number ) : void => {
4064- setNumericTextboxValues ( prev => ( {
4065- ...prev ,
4066- [ numericTextboxId ] : value || 0
4067- } ) ) ;
4100+ setNumericTextboxValues ( ( prev ) => {
4101+ const newState = {
4102+ ...prev ,
4103+ [ numericTextboxId ] : value || 0
4104+ } ;
4105+ numericTextboxValues = newState ;
4106+ return newState ;
4107+ } ) ;
40684108 }
40694109
40704110 const buttonClickActions = ( e : React . MouseEvent < HTMLButtonElement > ) => {
@@ -4328,7 +4368,7 @@ export const App = () => {
43284368 } }
43294369 cssClass = { localization . current === 'ar' ? "checkbox-content e-rtl" : "checkbox-content" }
43304370 label = { groupItem . label }
4331- checked = { checkboxStates [ groupItem . id ] ?? groupItem . defaultChecked }
4371+ checked = { tempCheckboxStates [ groupItem . id ] ?? groupItem . defaultChecked }
43324372 created = { ( ) => checkboxCreated ( groupItem . id , checkboxRefs . current ) }
43334373 change = { ( e ) => handleCheckboxChange ( groupItem . id , e . checked , checkboxRefs . current ) }
43344374 />
@@ -4501,7 +4541,7 @@ export const App = () => {
45014541 } }
45024542 cssClass = { localization . current === 'ar' ? "e-group-checkbox e-rtl" : "e-group-checkbox" }
45034543 label = { groupItem . label }
4504- checked = { checkboxStates [ groupItem . id ] ?? groupItem . defaultChecked }
4544+ checked = { tempCheckboxStates [ groupItem . id ] ?? groupItem . defaultChecked }
45054545 created = { ( ) => checkboxCreated ( groupItem . id , checkboxRefs . current ) }
45064546 change = { ( e ) => handleCheckboxChange ( groupItem . id , e . checked , checkboxRefs . current ) }
45074547 />
0 commit comments