Here is the custom paging solution we implemented for Kendo ListView. With minor changes, it should work for the grid. The solution consists of a custom DataSoure object and a custom JSonResult class.
User data source:
public class MyDataSource { public object AggregateResults { get; set; } public object Data { get; set; } public object Errors { get; set; } public int Total { get; set; } }
Custom ActionResult:
public class JsonNetResult : ActionResult { public Encoding ContentEncoding { get; set; } public string ContentType { get; set; } public object Data { get; set; } public JsonSerializerSettings SerializerSettings { get; set; } public Formatting Formatting { get; set; } public JsonNetResult() { SerializerSettings = new JsonSerializerSettings(); } public override void ExecuteResult(ControllerContext context) { if (context == null) throw new ArgumentNullException("context"); HttpResponseBase response = context.HttpContext.Response; response.ContentType = !string.IsNullOrEmpty(ContentType) ? ContentType : "application/json"; if (ContentEncoding != null) response.ContentEncoding = ContentEncoding; if (Data != null) { var writer = new JsonTextWriter(response.Output) { Formatting = Formatting }; JsonSerializer serializer = JsonSerializer.Create(SerializerSettings); serializer.Serialize(writer, Data); writer.Flush(); } }
A Typical use in an action method:
public ActionResult Orders_Read([DataSourceRequest] Object request) { int count = 0; var ds = (DataSourceRequest)request; var ListOfItemsToDisplay = GetItemsWithPagingInfo ( MySearchParameters, ds.PageSize, ds.Page, out count ); return new JsonNetResult { Formatting = Formatting.Indented, Data = new MyDataSource { Data = ListOfItemsToDisplay Total = count, AggregateResults = null, Errors = null } }; }
Jtmon source share