check box checked state issue

Hi,
I used below code but still i am unable to save the checkbox state when expand and collapse accordion item. Please help

var dynamicHeader = " Include ";
let id= 'accordionitemid';
webix.ui({
// global layout events
onClick: {
onAfterExpand: function (id) {
if (id == "accordionitemid") {
$$(id).$view.querySelector(".header-chkbx").checked = isChecked
}
},
onAfterCollapse: function (id) {
if (id == "accordionitemid") {
$$(id).$view.querySelector(".header-chkbx").checked = isChecked
}
}
},

                });


                var config = {


                    rows: [{
                        view: "accordionitem",
                        id: 'accordionitemid',





                        header: 'Registration' + dynamicHeader,

                        onClick: {

                            "header-chkbx": function (event, accordionId, elem) {


                                isChecked = elem.checked

                                    webix.message("checkbox clicked");
                                return false;
                            }

                        },
                        body: registrationUI,





                    }]
                };




                var view = webix.ui(config);
                $$('registration_acc_id').addView(view.getChildViews()[0]);

Hello,

Please check the sample: Code Snippet
In the sample you can see that I wrap the view and events into webix.ui , it helps the widget “to work” correctly. Also you need to declare the variable as
var isChecked = 0;

yes i also added var isChecked = 0; still its not saving the checkbox state as checked when the accordion is expanded or collapsed.