disactivated Combobox via checkbox

2 Answers 131 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?

2 Answers, 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/.

0
Alan
Top achievements
Rank 2
Iron
Iron
answered on 21 May 2022, 10:39 AM

I hate writing a lot of code...  my approach would be:

$(".k-checkbox").on("change", function () {

  $("#kComboBox").data("kendoComboBox").enable(this.checked);

}

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