How to know the index or hierachy of the selected item ?

6 posts, 0 answers
  1. Erik
    Erik avatar
    2 posts
    Member since:
    Jan 2012

    Posted 28 Jan 2012 Link to this post

    I would like to create a panel bar from a JSON object which is forged on basis of some nested array application data.
    At some moment, I want to know the currents selection of the panel bar, and do something with corresponding selection of my original data.
    However the .selected() method of the panelbar object returns the selected DOM element, and not a kind of index.
    How to figure out what number of list element that actually is?

    Suppose we have the panelbar as created in the panelbar basic demo, and we have selected the 'Q3 forecast' of the 'Sales forecast' of the Projects, then I would idealy want to know its relative index, something like 1,1,2. 

    I studied the onSelect function of the panelbar API demo, but that does the tric the otherway arround.
    Any suggestion, or do I perhaps misunderstand the concept of a panelbar  in the first place? 

  2. Kamen Bundev
    Admin
    Kamen Bundev avatar
    1532 posts

    Posted 01 Feb 2012 Link to this post

    Hello Erik,

    You can use the jQuery index() method to get the current index of the item on the same level. Check this jsFiddle on how to do it hierarchically:


    Kind regards,
    Kamen Bundev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. Kendo UI is VS 2017 Ready
  4. Erik
    Erik avatar
    2 posts
    Member since:
    Jan 2012

    Posted 02 Feb 2012 Link to this post

    Thanks Camen,

    You are really a jQuery wizzard. You fiddle works like a charm. Not something I could have come up with by poking around the last weeks in www.w3schools.com....
    Perhaps a good idea for a panelbar.selectIndex method?

    Erik

  5. Kamen Bundev
    Admin
    Kamen Bundev avatar
    1532 posts

    Posted 06 Feb 2012 Link to this post

    Hello Erik,

    We will consider to add such a method in one of the future releases. Meanwhile you can use the Kendo UserVoice Feedback page to add this as a feature request.

    Greetings,
    Kamen Bundev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  6. Stephane
    Stephane avatar
    3 posts
    Member since:
    Apr 2012

    Posted 27 Apr 2012 Link to this post

    The solution to get the current item select is perfect for me.

    Now I want to use it to reopen the panel at the same location and select the item if I reload my web page.

    How can I do it?

    Thanks
  7. Kamen Bundev
    Admin
    Kamen Bundev avatar
    1532 posts

    Posted 02 May 2012 Link to this post

    Hello Stephane,

    Check the updated fiddle below for how you can select back the specified element:


    Greetings,
    Kamen Bundev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top
Kendo UI is VS 2017 Ready