This is a migrated thread and some comments may be shown as answers.

Disable Parent Selection

2 Answers 498 Views
DropDownTree
This is a migrated thread and some comments may be shown as answers.
William
Top achievements
Rank 1
William asked on 01 Apr 2019, 07:42 PM
Is there a way to disable parent selection?  I only want the user to be able to select one child node.

2 Answers, 1 is accepted

Sort by
0
William
Top achievements
Rank 1
answered on 01 Apr 2019, 10:01 PM

I may have figured out one way to do this.  I added the select event and then added this script to the razor view.

        function onDropDownSelect(e) {
            var dataitem = e.sender.dataItem(e.node);
            console.log(dataitem);
            if (dataitem.hasChildren) {
                e.preventDefault();
            }
        }

Two questions:

1) Is this the best way to do this?

2) I initially tried to include this function in a javascript file that I include in the view but it could not find the function.  Is there a way to put this in a js file and include the js file as I like to keep my razor clean?

0
Accepted
Petar
Telerik team
answered on 02 Apr 2019, 02:11 PM
Hello William,

Here are the answers to your questions:
  1. Question 1: Yes, the approach you are using is the proper way of preventing selection of parent nodes.
  2. Question 2: Please check this Static files in ASP.NET Core article for detailed instructions about all the needed configurations you must set to include your JavaScript file. 

Regards,
Petar
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
DropDownTree
Asked by
William
Top achievements
Rank 1
Answers by
William
Top achievements
Rank 1
Petar
Telerik team
Share this question
or