我正在开发一个ASP.net MVC项目,我正在尝试创建一个Kendo Grid。网格出现在浏览器中并显示数据但是当我尝试添加一些事件时,intellisence没有显示例如.Sort()(和.Group(),。Page(),.Filter()...)in事件方法,如果我尝试使用它们,我会收到此错误:
'GridEventBuilder'不包含'Sort'的定义,并且没有扩展方法'Sort'接受类型'GridEventBuilder'的第一个参数可以找到(你是否缺少using指令或汇编引用?)
这是观点:
@(Html.Kendo().Grid<BekProject.Models.UserGroup>()
.Name("UserGroupGrid")
.Columns(columns =>
{
columns.Bound(c => c.Name).Title("Product Name");
columns.Bound(c => c.CreationDate).Title("Product Name");
})
.Pageable(pageable => pageable.ButtonCount(5))
.Sortable(sortable => sortable.AllowUnsort(false))
.Filterable()
.Editable()
.Groupable()
.Scrollable()
.Selectable(selectable => selectable
.Mode(GridSelectionMode.Multiple)
.Type(GridSelectionType.Cell)
)
.Events(events => events
.Change("onChange")
.DataBound("onDataBound")
.DataBinding("onDataBinding")
// !!!!!!!!!!!!!!!!!!!!!!!!!!! .sort is highlighted as error
.Sort("onSorting")
.Group("onGrouping")
.Page("onPaging")
.Filter("onFiltering")
)
.DataSource(dataSource => dataSource
.Ajax()
.Events(events => events.Error("grid_errorHandler"))
.Read(read => read.Action("UserGroups_Read", "UserGroupGrid"))
)
)
控制器:
public class UserGroupGridController : Controller
{
private MainContext db = new MainContext();
public ActionResult Index()
{
return View();
}
public ActionResult UserGroups_Read([DataSourceRequest]DataSourceRequest request)
{
IQueryable<UserGroup> usergroups = db.UserGroups;
DataSourceResult result = usergroups.ToDataSourceResult(request, userGroup => new {
UserGroupId = userGroup.UserGroupId,
Name = userGroup.Name,
CreationDate = userGroup.CreationDate
});
return Json(result);
}
public ActionResult Events()
{
return View();
}
public ActionResult Sorting()
{
return View();
}
protected override void Dispose(bool disposing)
{
db.Dispose();
base.Dispose(disposing);
}
}
有谁知道我怎么解决它?
答案 0 :(得分:0)
确保以下内容:
kendo.aspnetmvc.js
and kendo.web.js
)