由于Batch
更新更好地满足了我们的要求,因此尝试使用KendoUI for MVC创建具有编辑模式InCell
的TreeList。 (inline
正常工作。)
演示链接:https://demos.telerik.com/aspnet-mvc/treelist/editing-incell
在“工具栏”部分下,它接受“创建”方法,但是对于“保存”和“取消”它会抛出,
'TreeListToolbarFactory<>' does not contain definition for 'Save' and no extension method 'Save' accepting first argument of type 'TreeListToolbarFactory<>' could not be found.
对于它抛出的TreeListEditMode.InCell,
The name does not exist in the current context
剃刀代码
@(Html.Kendo().TreeList<KendoEx.Web.Models.Level>()
.Name("lvlTreeList")
.Toolbar(toolbar =>
{
toolbar.Create();
toolbar.Save();
toolbar.Cancel();
})
.Columns(columns =>
{
columns.Add().Field(e => e.LvlName).Title("Name").Width(220);
columns.Add().Field(e => e.LvlType).Title("Type").Width(100);
columns.Add().Command(c =>
{
c.CreateChild().Text("Add child");
c.Edit();
c.Destroy();
}
).Width(240);
})
.Editable(e => e.Mode(TreeListEditMode.InCell))
.DataSource(dataSource => dataSource
.Read(read => read.Action("GetLevel", "Level"))
.Create(create => create.Action("Save", "Level"))
.Update(update => update.Action("Save", "Level"))
.Destroy(delete => delete.Action("Remove", "Level"))
.Model(m =>
{
m.Id(f => f.Id);
m.ParentId(f => f.ParentLvl).DefaultValue(0);
m.Expanded(true);
m.Field(f => f.LvlName);
m.Field(f => f.LvlType);
})
)
.Height(550)
)
型号
public class Level
{
public int Id { get; set; }
public string LvlName { get; set; }
public string LvlType { get; set; }
public int? ParentLvl { get; set; }
public bool hasChildren { get; set; }
}
Version Info: Telerik 2018.1.221.545, MVC 5.2, .NET 4.6
请对此提供建议。