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

[Solved] SelectedIndex problem

1 Answer 75 Views
Menu
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
quentinjs
Top achievements
Rank 1
quentinjs asked on 11 Nov 2009, 07:47 AM
I started with the binding example where there was a selected index, got an exception raised.  Since I wanted a simple example I tried it with a different example provided and it failed here as well.  Perhaps I am missing a setting, but if I used the SelectedIndex( XX )  it will raise an exception of:

Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index


which makes sense as the menu isn't even populated when this is executed so it would be a valid error. 

    Html.Telerik().Menu()
     .Name("Menu")
     .SelectedIndex(1)
     .Orientation(MenuOrientation.Vertical)
     .Items(items =>
     {
         items.Add().Text("Item 1");
         items.Add().Text("Item 2");
     })
   .Render();


1 Answer, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 11 Nov 2009, 09:50 AM
Hi Quentin,

You should place SelectedIndex after Items method. This was fixed already and it is available as an internal build, but you should be client to download it. Here is the correct definition of the component:
Html.Telerik().Menu()
     .Name("Menu")
     .Orientation(MenuOrientation.Vertical)
     .Items(items =>
     {
         items.Add().Text("Item 1");
         items.Add().Text("Item 2");
     })
   .SelectedIndex(1)
   .Render();


Sincerely yours,
Georgi Krustev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Menu
Asked by
quentinjs
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Share this question
or