Style Kendo TreeView Checkboxes as Switches?

1 Answer 60 Views
Switch TreeView
Ryan
Top achievements
Rank 1
Ryan asked on 27 Apr 2023, 06:34 PM
Is there a way to have switches instead of checkboxes (same look as the kendoSwitch control) in a TreeView as seen in the example below?



I am dynamically converting the checkboxes after the treeview initializes using a function that basically does this 
$('input[type="checkbox"]:not([data-role="switch"])').kendoSwitch()
but it seems to have a lot of quirks that we have had to work around. Does the newest version of Kendo support switches in a TreeView out of the box?

1 Answer, 1 is accepted

Sort by
0
Nikolay
Telerik team
answered on 02 May 2023, 09:14 AM

Hi Ryan,

There is no built-in option for this, however, it can be achieved with checkboxes.template. For example:

      $("#treeview").kendoTreeView({
        template: '<input class="switch" type="checkbox" />',
        dataSource: [
          { text: "foo", inStock: 7, items: [
            { text: "bar", inStock: 2 },
            { text: "baz", inStock: 5 }
          ] }
        ]
      });
      $(".switch").kendoSwitch()

Dojo demo: https://dojo.telerik.com/EtasOLAK

I hope this helps.

Regards,
Nikolay
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
Switch TreeView
Asked by
Ryan
Top achievements
Rank 1
Answers by
Nikolay
Telerik team
Share this question
or