2013-04-21 68 views
2

在kendo網站上給出的示例中:http://demos.kendoui.com/web/panelbar/api.html,它顯示瞭如何以編程方式通過索引位置選擇項目。KendoUI:通過項目屬性選擇面板欄項目

那我該如何選擇一個基於ID的項目?

這是我如何結合我的模型,我Panelbar控制:

.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; 
     }) 

所以,我想選擇基於該數據GROUPID一個節點,我怎麼會去這樣做呢?

回答

1

,我建議你去嘗試這樣的事:

.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; 
     } 
    })