disactivated Combobox via checkbox

1 Answer 13 Views
ComboBox
Stevanus
Top achievements
Rank 1
Stevanus asked on 18 Oct 2021, 08:02 AM

hallo,

i just wanna to disable the combobox when the chekcbox is checked and vice versa.

 

when i cheked, it disactivated, but when i check out (isChek == false) is not enable it. so it remain disabled.

 

any idea?

1 Answer, 1 is accepted

Sort by
0
Alexander
Telerik team
answered on 20 Oct 2021, 02:50 PM

Hi, Stevanus

Thank you for the provided information and screenshot.

In the example provided changing the state of the checkbox may result in a component being initialized multiple times from the same DOM element. Instead, reference the widget instance using the following methods:

In general, the Telerik UI Check Box Html Helper for ASP.NET MVC is based on the conventional HTML checkbox element. In order to achieve the desired result, you can access the CheckBox through the classes Telerik UI for ASP.NET MVC generates for it.

Also, more information on how checkboxes are generated is available in the jQuery Check Boxes documentation for the classes.

Having said that, in order to achieve the desired result you can add an on-change event that:

  • Checks if the check box is checked through the .checked property (highlighted in blue).
  • Sets .enable() method on the combo box depending on the statement it goes to (highlighted in orange).

Finally, You can review the dojo sample for this scenario specifically:

   $(".k-checkbox").on("change", function () {
       if (this.checked) {
           $("#kComboBox").data("kendoComboBox").enable(false);
       }
       else {
           $("#kComboBox").data("kendoComboBox").enable(true);
       }
    });
 

In this example, I have added an on-change event to the check box with a reference to the widget instance of the combo box. Additionally, I have changed it to be enabled or disabled depending on whether the check box is checked or not. 

Please let me know if you have any further questions, and I would gladly answer them.

Regards, Alexander Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
ComboBox
Asked by
Stevanus
Top achievements
Rank 1
Answers by
Alexander
Telerik team
Share this question
or