我有kendo treeview来显示历史列表,所以最初我有1个项目然后从远程数据加载其子项。这是我的剃刀代码:
@(Html.Kendo().TreeView()
.Name("tvHistory")
.Animation(animation => animation.Expand(open =>
{
open.Expand(ExpandDirection.Vertical);
open.Fade(FadeDirection.In);
}))
.Items(treeview => treeview.Add().Text("History").Id(Model.Id.ToString()))
.DataTextField("Description")
.AutoBind(false)
.DataSource(dataSource => dataSource.Read(read => read.Action("History", "Reservation")))
)
技术上这个" 历史"单击项目将调用数据源读取操作并从控制器加载其子项目。然而,它在控制台中产生错误而不是调用控制器。
这是我的控制器代码和我返回客户端的类
[HttpGet]
public ActionResult History(int id)
{
IList<ReservationHistory> histories = _reservationService.GetHistoryFor(id).DataList;
IList<ReservationHistoryViewModel> viewModels = histories.ToModel<ReservationHistory, ReservationHistoryViewModel>();
return Json(viewModels, JsonRequestBehavior.AllowGet);
}
public class ReservationHistoryViewModel
{
public int Id { get; set; }
public int ReservationId { get; set; }
public string Description { get; set; }
}
有任何解决此问题的建议吗?感谢