我有这样的看法:
@model MySearchVM
//Filters
...
@Html.TextBoxFor(model => model.Description)
@Html.TextBoxFor(model => model.Letter)
...
//Grid
@(Html.Kendo().Grid<MyGridVM>()
.Name("MyGrid")
.Columns(columns =>
{
columns.Bound(p => p.Id).Hidden(true);
columns.Bound(p => p.Description);
columns.Bound(p => p.Letter);
})
.Groupable()
.Pageable()
.Sortable()
.Scrollable()
.DataSource(dataSource => dataSource
.Ajax()
.Read(read => read.Action("_Read", "MyController"))
.Model(model => model.Id(p => p.Id)))
)
我的控制器:
public ActionResult _Read([DataSourceRequest] DataSourceRequest request)
{
var list = repository.GetAll().Select(x => new MyGridVM()
{
Id = x.Id,
Description = x.Description,
Letter = x.Letter,
});
return Json(list.ToDataSourceResult(request));
}
一切都很好......但我想在 _Read 操作中访问我的 ViewModel,所以我可以手动过滤结果......
我试图通过 FormCollection,但只能从以下位置获得:排序、页面、pageSize、组和过滤器
我怎样才能做到这一点?
谢谢