Null Reference
Null Reference

Reputation: 11340

KendoUI: Selecting panelbar item by item property

In the example given on kendo's website: http://demos.kendoui.com/web/panelbar/api.html, it shows how you can programmatically select an item by the index position.

How do I then, select an item based on an Id?

This is how I'm binding my model to my Panelbar control:

.BindTo(Model.FloorPlanGroups, mappings =>
    {
         mappings.For<Asis.Ibss.Web.Mvc.Areas.Monitoring.Models.FloorPlanGroupModel>(itemDataBound =>
        itemDataBound.ItemDataBound((item, group) =>
        {
           item.Text = group.Name;
           item.HtmlAttributes["data-groupid"] = group.Id;
         })

So, I would like to select a node based on the data-groupid, how would I go about doing it?

Upvotes: 2

Views: 2505

Answers (1)

Petur Subev
Petur Subev

Reputation: 20203

I suggest you to try something like this:

.BindTo(Model.FloorPlanGroups, mappings =>
{
     mappings.For<Asis.Ibss.Web.Mvc.Areas.Monitoring.Models.FloorPlanGroupModel>(itemDataBound =>
    itemDataBound.ItemDataBound((item, group) =>
    {
       item.Text = group.Name;
       item.HtmlAttributes["data-groupid"] = group.Id;
       if(group.Id==5){
            item.Selected=true;
       }
     })

Upvotes: 1

Related Questions