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

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

5 Answers 244 Views
PanelBar
This is a migrated thread and some comments may be shown as answers.
Erik
Top achievements
Rank 1
Erik asked on 29 Jan 2012, 04:34 AM
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? 

5 Answers, 1 is accepted

Sort by
0
Kamen Bundev
Telerik team
answered on 01 Feb 2012, 09:44 AM
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!
0
Erik
Top achievements
Rank 1
answered on 02 Feb 2012, 09:38 PM
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

0
Kamen Bundev
Telerik team
answered on 06 Feb 2012, 10:29 AM
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!
0
Stephane
Top achievements
Rank 1
answered on 27 Apr 2012, 02:23 PM
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
0
Kamen Bundev
Telerik team
answered on 02 May 2012, 09:06 AM
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!
Tags
PanelBar
Asked by
Erik
Top achievements
Rank 1
Answers by
Kamen Bundev
Telerik team
Erik
Top achievements
Rank 1
Stephane
Top achievements
Rank 1
Share this question
or