【发布时间】:2015-02-07 17:23:15
【问题描述】:
我在我的 ASP.NET MVC 项目中使用 Kendo UI TreeView 和 Kendo UI MVC Wrappers。
我的视图中有 HTML 表单。这是我的视图的代码:
<form method="POST" action="@Url.Action("Review")">
@* ... *@
@(Html.Kendo().TreeView()
.Name("CategoryId")
.DataTextField("Name")
.DataSource(dataSource => dataSource
.Read(read => read.Action("Categories", "ReviewCategories"))
)
)
@* ... *@
<input type="submit" class="btn btn-primary" value="Submit" />
</form>
树视图运行良好。这是Categoriesaction的代码:
public JsonResult Categories(int? id)
{
var categories = this.forumCategoriesService.All()
.Where(x => id.HasValue ? x.ParentId == id : x.ParentId == null)
.Select(x => new { id = x.Id, Name = x.Title, hasChildren = x.Children.Any() });
return this.Json(categories, JsonRequestBehavior.AllowGet);
}
问题是,当我点击submit 按钮时,表单会发送除所选CategoryId 的值以外的所有数据。
当我提交表单时,让 Kendo UI TreeView 发送CategoryId 的最优雅的方式是什么?
(如果没有简单的方法将其作为输入值发送,我将接受任何自定义 JavaScript 代码解决方案)
【问题讨论】:
标签: kendo-ui kendo-asp.net-mvc kendo-treeview