这是我的模型,我想在网格上显示lesCategories,在文本框上显示Nom:
public class StructureTypeViewModel
{
public StructureTypeViewModel()
{
this.Nom = "";
this.LesCategories = new List<CategorieTemplateViewModel>();
}
[ScaffoldColumn(false)]
public int StructureID
{
get;
set;
}
[Required]
[Display(Name = "Le nom de la structure")]
public string Nom { get; set; }
[Required]
[Display(Name = "Les catégories")]
public List<CategorieTemplateViewModel> LesCategories { get; set; }
}
在这里我的观点:
@using Kendo.Mvc.UI
@model Parmenide.PoliceGenerator.Web.Template.Models.StructureTypeViewModel
<style>
.form-special {
padding-right: 15px;
padding-left: 15px;
max-width: 75%;
}
</style>
<div class="form-special">
<div class="form-group">
@Html.LabelFor(m => m.Nom)
@(Html.Kendo().TextBoxFor(m => m.Nom)
.HtmlAttributes(new {placeholder = "Ex : Struture n°1", type = "text", @class = "k-textbox required"})
)
</div>
@(Html.Kendo().Grid(Model.LesCategories)
.Name("grid")
.Columns(columns =>
{
columns.Bound(c => c.Nom);
columns.Command(command => command.Destroy()).Width(150);
})
.ToolBar(
toolbar =>
{
toolbar.Create().Text("Ajouter une catégorie");
})
.Editable(editable => editable.Mode(GridEditMode.InCell))
.Pageable()
.Sortable()
.Scrollable()
.HtmlAttributes(new {style = "height:250px;"})
.DataSource(dataSource => dataSource
.Ajax()
.Batch(true)
.ServerOperation(false)
.Model(model =>
{
model.Id(p => p.CategorieID);
})
.PageSize(5)
.Create(create => create.Action("EditingCustom_Create", "Home"))
.Update(update => update.Action("EditingCustom_Update", "Home"))
.Destroy(destroy => destroy.Action("EditingCustom_Destroy", "Home"))
)
)
我在创建更新销毁操作时遇到问题我不明白获取CategorieViewModel的当前列表的语法。