We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Script error throws for exceeding maxJson length while performing serialization or deserialization

 

Problem:

While binding very large data to the grid it throws a following exception.

Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property.

Cause:

In our latest MVC grid, we have rendered all the html elements in client side and we have passed the data to the control from server side to client side as Json data by serializing it.

And we have used the default MaxJsonLength value (2097152 characters, which is equivalent to 4 MB of Unicode string data) of the JavaScriptSerializer which is a fixed universal standard length for serializing the data.

We can also use custom serializer to serialize the data Source, this can be done as follows.

Even though custom serializer serialize large amount of data, it will also lead to out of memory exception.

Solution:

We have provided the following features to overcome the maxJsonLength issue.

1. Load on demand

2. Virtual Scrolling

Example:

1. Load on Demand

We have used UrlAdaptor to get the data from the controller through post action and bound the Json result as a grid data source.

Please refer the below code snippet

Also when we use UrlAdaptor, we need to return the data as JSON and the JSON object must contain field name as “result” with its value as dataSource and one more field name as “count” with its value as dataSource total records count.

For paging we have used “PerformSkip” and “PerformTake” method of DataOperation class to get skip and take count of the records.

 

Result:

cid:image001.png@01CFFE9B.52D4D6A0

 

cid:image004.png@01CFFE42.669C2700

 

2. Virtual Scrolling

 

Please refer the below online demo link for more clarification about Virtual Scrolling feature.

Online Demo Link:http://js.syncfusion.com/demos/web/#!/azure/grid/Paging/VirtualPaging

Result:

 

Article ID: Published Date: Last Revised Date: Platform: Control:
3063 12/24/2014 08/04/2015 ASP.NET MVC Grid
Tags:
Did you find this information helpful?
Add Comment
You must log in to leave a comment

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.