ComboBox Grouping and SelectedIndex

2 posts, 0 answers
  1. Monkey
    Monkey avatar
    1 posts
    Member since:
    May 2013

    Posted 05 Apr Link to this post

    I've got a ComboBox which uses Grouping and I'm having trouble setting the selected item:

                      .HtmlAttributes(new { style = "width:100%;" })
                      .DataSource(source => source
                          .Group(g => g.Add("GroupKey", typeof(string)))
                          .Transport(transport => transport
                              .Read(read =>
                                  read.Action("GetMyItems", "MyController");

    My controler is returning JSON in the following format with one of the items optionally having "Selected":true

    [{"GroupKey":"Address","GroupName":"Address","Selected":false,"Text":"Correspondence Post Code","Value":"821"},...etc..]

  2. Ivan Danchev
    Ivan Danchev avatar
    829 posts

    Posted 07 Apr Link to this post

    Hello Kevin,

    The ComboBox will not pre-select an item that has a property Selected set to "true". Selecting an item can be done either by specified either by using the SelectedIndex() method (calling it with the index of the item you want to be selected, for example: SelectedIndex(3)) or by using the Value() method, to which you can pass the text of the item you want to select, for instance: Value("Item1").

    Ivan Danchev
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. UI for ASP.NET MVC is VS 2017 Ready
Back to Top