剑道MVC的ListView编辑 [英] Kendo MVC ListView Editing
问题描述
请检查下面的code
please check the below code
@model IEnumerable<Polls.Core.domain.Address>
<div class="demo-section">
<a class="k-button k-button-icontext k-add-button" href="#"><span class="k-icon k-add"></span>Add new record</a>
</div>
<script type="text/x-kendo-tmpl" id="template">
<div class="product-view k-widget">
<div class="edit-buttons">
<a class="k-button k-button-icontext k-edit-button" href="\\#"><span class="k-icon k-edit"></span></a>
<a class="k-button k-button-icontext k-delete-button" href="\\#"><span class="k-icon k-delete"></span></a>
</div>
<dl>
<dt>AddressType</dt>
<dd>#:AddressType#</dd>
<dt>Line1</dt>
<dd>#:Line1#</dd>
<dt>Line2</dt>
<dd>#:Line2#</dd>
<dt>Line3</dt>
<dd>#:Line3#</dd>
<dt>City</dt>
<dd>#:City#</dd>
<dt>State</dt>
<dd>#:State#</dd>
</dl>
</div>
</script>
<script type="text/x-kendo-tmpl" id="editTemplate">
<div class="product-view k-widget">
<div class="edit-buttons">
<a class="k-button k-button-icontext k-update-button" href="\\#"><span class="k-icon k-update"></span>Save</a>
<a class="k-button k-button-icontext k-cancel-button" href="\\#"><span class="k-icon k-cancel"></span>Cancel</a>
</div>
<dl>
<dt>AddressType</dt>
<dd>#:AddressType#</dd>
<dt>Line1</dt>
<dd>#:Line1#</dd>
<dt>Line2</dt>
<dd>#:Line2#</dd>
<dt>Line3</dt>
<dd>#:Line3#</dd>
<dt>City</dt>
<dd>#:City#</dd>
<dt>State</dt>
<dd>#:State#</dd>
</dl>
</div>
</script>
<div class="demo-section">
@(Html.Kendo().ListView<Polls.Core.domain.Address>(Model)
.Name("listView")
.TagName("div")
.ClientTemplateId("template")
.Editable(editor => editor.TemplateName("editTemplate"))
.Pageable()
.DataSource(dataSource => dataSource
.Model(model => model.Id("Id"))
.PageSize(6)
.Create(create => create.Action("Address_Create", "Test"))
.Read(read => read.Action("Address_Read", "Test"))
.Update(update => update.Action("Address_Update", "Test"))
.Destroy(destroy => destroy.Action("Address_Destroy", "Test"))
)
)
</div>
<script>
$(function () {
var listView = $("#listView").data("kendoListView");
$(".k-add-button").click(function (e) {
listView.add();
e.preventDefault();
});
});
</script>
有人指导如何引用编辑模板。目前,当我点击编辑/添加新的按钮,它显示在模型中所有可用的实体。我只希望所选字段出现在编辑。
Someone guide how to refer the Edit Template. Currently when I click the Edit / Add New Button it show all the entity available in model. I want only the selected fields to appear while editing.
有人请这方面的帮助。
Someone please help in this regard.
推荐答案
剑道MVC使用的文件夹引用编辑模板,这个文件夹,你会找到它查看/共享/ EditorTemplates(如果该文件夹不存在,就创建它) 。此文件夹中可以插入你会按名称调用模板,例如:
Kendo MVC uses a folder to reference edit templates this folder you will find it at View/Shared/EditorTemplates (If the folder does not exist, just create it). Inside this folder you can insert all the templates you will call by name, example:
@(Html.Kendo().ListView<temp.Models.YourTable>(Model)
.Name("listView")
.TagName("div")
.ClientTemplateId("template") // here goes the template for data
.DataSource(dataSource => dataSource
.Model(m => m.Id("ID"))
.ServerOperation(false)
.Read(read => read.Action("ActionRead", "Controller"))
)
.Editable(edit => edit.TemplateName("EditTmpl")) // here goes the template name for edit mode
)
EditTmpl.cshtml => //这个模板是你必须在我前面引用的文件夹中存储的人。
EditTmpl.cshtml => // this template is the one that you must store in the folder that I refer above.
希望这有助于。
这篇关于剑道MVC的ListView编辑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!