I am using telerik grid for display data from sql db… When I displaying more than 3500 rows, it returns: Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property.
Everywhere on internet and Telerik Troubleshooting manual also too, wrote that reason is edit web.config. It doesn’t help me… I tryed return data like this:
JavaScriptSerializer serializer = new JavaScriptSerializer { MaxJsonLength = 536870912, RecursionLimit = 100 };
return new ContentResult()
{
Content = serializer.Serialize(data),
ContentEncoding = Encoding.UTF8
};
When I return data as ContentResult, filtering and sorting stops working.
I was trying this solution too: http://anyrest.wordpress.com/2011/09/27/large-json-result-for-teleriks-mvc-grid/ and it isn’t helps me…
Here is code from my Controller:
[GridAction, POST("GridData")]
public ActionResult _Index()
{
var data = GetExclusionsDataCollection();
return View(new GridModel { Data = data });
}
Thanks,
David
i contacted Telerik support and now I can share reason of my issue…
There is link to Telerik Code library. Important part is adding line into global.asax.cs. This part of their solution isn’t in most of other solutions that i have seen…
This line causes ovveride default Telerik functionality and active your custom Json result…
-David