我有看起來像這樣在我的剃刀查看一個標籤條:綁定的ViewModels到AJAX加載TabStrip控件的選項卡
@(Html.Kendo().TabStrip()
.Name("tabstrip")
.Items(tabstrip =>
{
foreach (var tab in @Model.Tabs.Values)
{
tabstrip.Add().Text(tab.Title)
.LoadContentFrom(tab.Title.Replace(" ", string.Empty), "Account"); //remove spaces for action methods
}
})
)
控制器返回每個選項卡的局部視圖。主視圖綁定到名爲AccountViewModel的視圖模型,該模型具有名爲Tabs的字典。選項卡將字符串映射到每個單獨選項卡的ViewModels。
在foreach循環的每次迭代中,選項卡實際上是我想綁定到正在加載的實驗室的ViewModel。
有沒有辦法將ViewModel,比方說,Tabs [「tabA」]綁定到由LoadContentFrom(「tabA」,「Account」)返回的局部視圖;?
你的意思是通過向視圖模型綁定到局部視圖?你希望'LoadContentFrom(「tabA」,「Account」)'返回一個帶有Tabs [「tabA」]的強類型局部視圖作爲模型,是嗎? – ataravati
是的,確切地說。選項卡[「tabA」]將是* tab *迭代器。 –