We are using Kendo controls (mainly Kendo Grid for web pages) in one of our web applications. Kendo's controls are very good in terms of simplicity that they bring to build standard (but slightly complex) web application features. However, sometimes you run into some strange issues.
One of our screens used client side paging feature of Kendo Grid and one day, out of nowhere, we started to notice exceptions like below:
Exception Type: System.InvalidOperationException Exception: System.InvalidOperationException: Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property.
at System.Web.Script.Serialization.JavaScriptSerializer.Serialize(Object obj,
SerializationFormat serializationFormat)
at Kendo.Mvc.Infrastructure.JavaScriptInitializer.Serialize(IDictionary`2
object)
at Kendo.Mvc.Infrastructure.JavaScriptInitializer.Serialize(IDictionary`2
object)
at Kendo.Mvc.Infrastructure.JavaScriptInitializer.Serialize(IDictionary`2
object)
at Kendo.Mvc.Infrastructure.JavaScriptInitializer.InitializeFor(String
selector, String name,
IDictionary`2 options)
at Kendo.Mvc.UI.Grid`1.WriteInitializationScript(TextWriter writer)
at Kendo.Mvc.UI.WidgetBase.WriteHtml(HtmlTextWriter
writer)
at Kendo.Mvc.UI.Grid`1.WriteHtml(HtmlTextWriter writer)
at Kendo.Mvc.UI.WidgetBase.ToHtmlString()
at Kendo.Mvc.UI.Fluent.WidgetBuilderBase`2.ToHtmlString()
at System.Web.WebPages.WebPageExecutingBase.WriteTo(TextWriter writer, Object content)
It was quite strange given that we did not have more than 5000 records and i hoped kendo's grid would be able to handle it. As it turned out, there were two reasons:
1. As a default, Kendo's controls use .NET's in-built JavaScriptSerializer class which has its own limitations. Good news is that Kendo controls give you a way to switch to JavaScript Serializer of your choice (JSON.Net in my case). This improved the # of records that could be handled by the grid. In fact, it simply doubled the # of records that could be handled through client side paging/sorting.
2. General recommendation from kendo (and it applies everywhere irrespective of if you are using a set of professional controls or building your own), is that a webpage should carry data that is absolutely required. In fact, every view in the page should have its own ViewModel class which is simple in structure.
No comments:
Post a Comment