Efficient way of limiting selection to child or parent items

4 posts, 0 answers
  1. Martez
    Martez avatar
    4 posts
    Member since:
    Jan 2015

    Posted 12 Apr 2015 Link to this post

    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?

  2. Martez
    Martez avatar
    4 posts
    Member since:
    Jan 2015

    Posted 12 Apr 2015 in reply to Martez Link to this post

    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 :-) 
  3. Kendo UI is VS 2017 Ready
  4. Alex Gyoshev
    Admin
    Alex Gyoshev avatar
    2500 posts

    Posted 14 Apr 2015 Link to this post

    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!
     
  5. Martez
    Martez avatar
    4 posts
    Member since:
    Jan 2015

    Posted 15 Apr 2015 in reply to Alex Gyoshev Link to this post

    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.

Back to Top
Kendo UI is VS 2017 Ready