The checkboxfor is not working after upgrading the kendo version from 2020.1.114 to 2022.1.119

1 Answer 275 Views
Checkbox
Alexander
Top achievements
Rank 1
Iron
Alexander asked on 09 May 2023, 02:18 AM



It is my checkbox code
<div class="row">
                        <div class="form-group">
                            <label class="form-label">
                                <span><b>@ResourceManagerClass.GetResource("CCTV Available", ProjectSession.Employee.LanguageId)</b></span>&nbsp;
                                @Html.Kendo().CheckBoxFor(x => x.IsCCTVAvailable).Checked(true).Enable(false).HtmlAttributes(new { @class = "form-control", @onclick = "ManageCCTVCameraInputBox(event)" }).ToClientTemplate()
                            </label>
                            <br />
                            <label class="form-label">
                                @ResourceManagerClass.GetResource("CCTV Detail", ProjectSession.Employee.LanguageId)
                            </label>
                            <br />
                            @(Html.TextAreaFor(x => x.CCTVDetail, 3, 5, new { @class = "form-control textAreaWith" }))
                        </div>
                    </div>




It is my function

function ManageCCTVCameraInputBox(e) {
        debugger
        if (e != undefined) {
            if (e.currentTarget.checked && e.currentTarget.id == "IsCCTVAvailable") {
                $('#CCTVDetail').prop('disabled', false);
            } else {
                $('#CCTVDetail').prop('disabled', true);
            }
        } else {
            if ('@Model.IsCCTVAvailable' == "True") {
                $('#CCTVDetail').prop('disabled', false);
            }
            else {
            $('#CCTVDetail').prop('disabled', true);
            }

        }
    }

This code is working fine in kendo 2020.1.114 after upgrading the checkboxes are not working so I have added Toclienttemplate() at the end of the textbox after adding Toclienttemplate() it is showing error unexpected error< 

So I didn't made any changes in script also but from where it is binding I didn't get it

Can anyone suggest me a answer or any reference link

 

Thanks

1 Answer, 1 is accepted

Sort by
0
Ivan Danchev
Telerik team
answered on 11 May 2023, 04:19 PM

Hello Hubert,

The CheckBox component does not expose a click event, so consider using its Change event:

Attach an event handler:

@Html.Kendo().CheckBoxFor(x => x.IsCCTVAvailable).Checked(true).Enable(true).Events(ev => ev.Change("onChange")).HtmlAttributes(new { @class = "form-control" })

The handler:

<script>
    function onChange(e) {
        //...your logic...
    }
</script>

Regards,
Ivan Danchev
Progress Telerik

Stay tuned by visiting our public roadmap and feedback portal pages. If you're new to the Telerik family, be sure to check out our getting started resources, as well as the only REPL playground for creating, saving, running, and sharing server-side code.

Adam
Top achievements
Rank 1
commented on 23 May 2023, 07:43 PM

Same problem here. I checked the page source and see where a script is generated that calls kendoCheckBox() but I'm getting console errors that this method doesn't exist. Sure enough when I check the kendo javascript file there is no trace of it when searching for "kendoCheckBox". Yet all other kendo controls (inputs, buttons, etc) seem to be working fine.
Ivan Danchev
Telerik team
commented on 26 May 2023, 01:27 PM

Adam,

The CheckBox widget was introduced in the R1 2022 release (version 2022.1.119). So, if your kendo.all.min.js file is older, you won't be able to initialize a CheckBox by calling the kendoCheckBox() function.

Tags
Checkbox
Asked by
Alexander
Top achievements
Rank 1
Iron
Answers by
Ivan Danchev
Telerik team
Share this question
or