1
我想要做的是創建一個網格,當你點擊它打開一個細節網格供用戶選擇。我創造了他們這樣Kendo Ui模型綁定3級對象
@(Html.Kendo().Grid(Model.items).Name("Access")
.Columns(columns =>
{
columns.Bound("ProjId").Width(220).Title("Project #");
})
.ClientDetailTemplateId("detailTemplateId")
.Selectable()
.Events(events => events.DetailInit("initDetailGrid"))
.DataSource(dataSource => dataSource
.Ajax()
.ServerOperation(false)
)
)
<script id="detailTemplateId" type="text/kendo-tmpl">
@(Html.Kendo().Grid(Model.items.subItems).Name("detailGrid")
.Columns(columns => columns.Bound("itemsName").Title("Select"))
.DataSource(dataSource => dataSource
.Ajax()
.ServerOperation(false)
)
.ToClientTemplate()
)
</script>
該模型是這樣的
public class ItemModel
{
public List<myItems> items;
public ItemModel()
{
items = new List<myItems>();
}
}
的myItems類別處定義創建,並且myItems類中的一個子類,這是我想的子項得到
public class myItems
{
public int ProjId;
public List<otherItems> subItems;
public myItems(){
subItems = new List<otherItems>();
}
public class otherItems()
{
public String itemsName;
public int itemId
}
}
但是當我試圖在這裏將它綁定@(Html.Kendo().Grid(Model.items.subItems).Name("detailGrid")
說,它不能解析符號?我是否正確地做這件事?還是必須將它綁定到項目,然後使用列模板獲取列內的值?