This is a migrated thread and some comments may be shown as answers.
Efficient way of limiting selection to child or parent items
3 Answers 11 Views
This is a migrated thread and some comments may be shown as answers.
Martez
Top achievements
Rank 1
Martez asked on 12 Apr 2015, 06:18 PM

I have two separate scenarios.  In both scenarios the treeview is 2 levels deep.

 Level 1A

     -Level 2a

     -Level 2b

Leve l 1B

 

I have hacked together some jquery but it is ugly and  I was wondering if there is an efficient way to in one case limit selections to top (parent) level nodes (Level 1A, Level 1B) and in the other case limit selections to child level nodes (Level 2a, Level 2b).  Maybe someway in the template to add a class to child level nodes or something of that sorts?

3 Answers, 1 is accepted

Sort by
0
Martez
Top achievements
Rank 1
answered on 12 Apr 2015, 06:29 PM
Sorry, I was completely over-thinking things and should be able to accomplish this rather easy using jquery selectors and the filter function.  Nevermind me :-) 
0
Alex Gyoshev
Telerik team
answered on 14 Apr 2015, 08:10 AM

Hello Martez,

You can also work with the select event and prevent it depending on the node level, like this:

  select: function(e) {
    if (this.dataItem(e.node).level() != 1) {
      e.preventDefault();
    }
  }

Regards,
Alex Gyoshev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Martez
Top achievements
Rank 1
answered on 15 Apr 2015, 10:20 AM

Hi Alex,

 Thanks for the response, while I was able to get this working your solution was much cleaner and I'll adopt your approach.

Asked by
Martez
Top achievements
Rank 1
Answers by
Martez
Top achievements
Rank 1
Alex Gyoshev
Telerik team
Share this question
or