Telerik MVC 网格错误
编译器错误消息:CS1977:无法使用 lambda 表达式作为动态分派操作的参数,而不先将其转换为委托或表达式树类型
我在此项目中使用存储库模式,因此我通过服务调用检索的数据而不是常规的 linq 查询。我不确定他们将争论交给代表或专家是什么意思。树类型。这是代码。
@(Html.Telerik().Grid(Model)
.Name("Grid").Columns(columns =>
{
columns.Bound(o => o.formId).Width(100);
columns.Bound(o => o.Name).Width(200);
//columns.Bound(o => o.ShipAddress);
//columns.Bound(o => o.OrderDate).Format("{0:MM/dd/yyyy}").Width(120);
})
.DataBinding(dataBinding =>
{
dataBinding.Server().Select("Index", "Grid", new { ajax = ViewData["ajax"] });
dataBinding.Ajax().Select("_Index", "Grid").Enabled((bool)ViewData["ajax"]);
})
.Scrollable(scrolling => scrolling.Enabled((bool)ViewData["scrolling"]))
.Sortable(sorting => sorting.Enabled((bool)ViewData["sorting"]))
.Pageable(paging => paging.Enabled((bool)ViewData["paging"]))
.Filterable(filtering => filtering.Enabled((bool)ViewData["filtering"]))
.Groupable(grouping => grouping.Enabled((bool)ViewData["grouping"]))
.Footer((bool)ViewData["showFooter"])
)
public ActionResult Index(bool? ajax, bool? scrolling, bool? paging, bool? filtering, bool? sorting,
bool? grouping, bool? showFooter)
{
ViewData["ajax"] = ajax ?? true;
ViewData["scrolling"] = scrolling ?? true;
ViewData["paging"] = paging ?? true;
ViewData["filtering"] = filtering ?? true;
ViewData["grouping"] = grouping ?? true;
ViewData["sorting"] = sorting ?? true;
ViewData["showFooter"] = showFooter ?? true;
return View(formService.GetForms());
}
[GridAction]
public ActionResult _Index()
{
return View(new GridModel(formService.GetForms()));
}
Compiler Error Message: CS1977: Cannot use a lambda expression as an argument to a dynamically dispatched operation without first casting it to a delegate or expression tree type
I am using the Respository pattern in this project, so the data i retrieved by way of service calls and not regular linq queries. I am unsure as to what they may mean by cast the arguement to a delegate or exp. tree type. here is the code.
@(Html.Telerik().Grid(Model)
.Name("Grid").Columns(columns =>
{
columns.Bound(o => o.formId).Width(100);
columns.Bound(o => o.Name).Width(200);
//columns.Bound(o => o.ShipAddress);
//columns.Bound(o => o.OrderDate).Format("{0:MM/dd/yyyy}").Width(120);
})
.DataBinding(dataBinding =>
{
dataBinding.Server().Select("Index", "Grid", new { ajax = ViewData["ajax"] });
dataBinding.Ajax().Select("_Index", "Grid").Enabled((bool)ViewData["ajax"]);
})
.Scrollable(scrolling => scrolling.Enabled((bool)ViewData["scrolling"]))
.Sortable(sorting => sorting.Enabled((bool)ViewData["sorting"]))
.Pageable(paging => paging.Enabled((bool)ViewData["paging"]))
.Filterable(filtering => filtering.Enabled((bool)ViewData["filtering"]))
.Groupable(grouping => grouping.Enabled((bool)ViewData["grouping"]))
.Footer((bool)ViewData["showFooter"])
)
public ActionResult Index(bool? ajax, bool? scrolling, bool? paging, bool? filtering, bool? sorting,
bool? grouping, bool? showFooter)
{
ViewData["ajax"] = ajax ?? true;
ViewData["scrolling"] = scrolling ?? true;
ViewData["paging"] = paging ?? true;
ViewData["filtering"] = filtering ?? true;
ViewData["grouping"] = grouping ?? true;
ViewData["sorting"] = sorting ?? true;
ViewData["showFooter"] = showFooter ?? true;
return View(formService.GetForms());
}
[GridAction]
public ActionResult _Index()
{
return View(new GridModel(formService.GetForms()));
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是我的疏忽,视图的返回类型是 Viewmodel 的类型,而不是来自服务模型的模型。
It was negligence on my part, the return type of the view was of the type of the Viewmodel as opposed to the model coming in from the service model.
你的模型中有一些动态的东西,不是吗?该错误表明 C# 无法从动态分派操作创建表达式。
如果要将 Telerik Grid for ASP.NET MVC 绑定到动态模型,请检查 此代码库项目。
There is something dynamic in your model, isn't it. The error is telling that C# can't create an expression from a dynamically dispatched operation.
If you want to bind Telerik Grid for ASP.NET MVC to dynamic model check this code library project.