or
public ActionResult Assigned([DataSourceRequest(Prefix = "Grid")] DataSourceRequest gridRequest){ if (gridRequest.PageSize == 0) { gridRequest.PageSize = 5; } var orders = _orderModel.GetDashboardOrders(DashboardOrderStatus.Assigned); if (gridRequest.Page > 0) { orders = orders.Skip((gridRequest.Page - 1)*gridRequest.PageSize).ToList(); } orders = orders.Take(gridRequest.PageSize).ToList(); ViewData["total"] = orders.Count; var model = new DashboardModel { SelectedTab = "Assigned", Orders = orders }; model = SetGlobalTabsBasedOnUserRole(model) as DashboardModel; return View(model);}@(Html.Kendo().Grid<ProjX.Web.Models.Entities.DashboardOrder> ().Name("Grid").EnableCustomBinding(true).BindTo(Model.Orders).TableHtmlAttributes(new {style="width: 850px;"}).Columns(columns => { <columns removed for readability, they work fine> }) .Pageable(x => x.PageSizes(true)) .DataSource(ds => ds .Server() .Total((int)ViewData["total"]) ))I have put the page and controller code in an older project (v2012.2.913) and the first two issues disappear.
The grid definition is:-
<div style="font-size:small;width:700px; margin-bottom:15px;">@(Html.Kendo().Grid<PMS2Monitor.Models.SystemSetting>().Name("settingsGrid").Columns(columns=> {columns.Bound(p=>p.SettingCode); columns.Bound(p => p.SettingDescription).Title("Description"); columns.Bound(p => p.SettingValue).Title("Value"); columns.Command(command => { command.Edit(); }); }) .Editable(editable=>editable .Mode(GridEditMode.InLine)) .Pageable() .Filterable() .DataSource(dataSource=>dataSource .Ajax() .Model(m=>m.Id(p=>p.SettingCode)) .PageSize(8) .Events(events => events.Error("error")) .Read(read=>read.Action("InterfaceSettings","Home")) .Update(update=>update.Action("UpdateSetting","Home")) ) ) </div>The object meta data is defined as:-
[MetadataType(typeof(SystemSettingMD))] public partial class SystemSetting { public class SystemSettingMD { [ReadOnly(true)] public object SettingCode { get; set; } [ReadOnly(true), StringLength(50)] public object SettingDescription { get; set; } [StringLength(500), Required] public object SettingValue { get; set; } } }The controller is:-
public ActionResult InterfaceSettings([DataSourceRequest] DataSourceRequest request) { var query = _repository.GetSettings(); query = query.OrderByDescending(c => c.SettingCode); return Json(query.ToDataSourceResult(request)); } [AcceptVerbs(HttpVerbs.Post)] public ActionResult UpdateSetting([DataSourceRequest] DataSourceRequest request, Models.SystemSetting setting) { try { _repository.updateSetting(setting); return Json(ModelState.ToDataSourceResult()); } catch (Exception ex) { ModelState.AddModelError("ERR1", ex.Message); return Json(ModelState.ToDataSourceResult()); } }I've attached a screenshot of the grid buttons.
Thanks
return Json(ModelState.IsValid ? new object(): ModelState.ToDataSourceResult());