This is a migrated thread and some comments may be shown as answers.

Modify the maxJsonLength

4 Answers 477 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Barry
Top achievements
Rank 1
Barry asked on 15 Apr 2011, 07:08 AM
Hi,

When populating a large amount of data in my telerik combobox I am encountering the error below.

Html.Telerik().ScriptRegistrar().jQuery(true) Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property.

Looking into some forums, it is stated that declaring the maxJsonLength property in the web.config is not possible in MVC since it will just be completely ignored. Please advice if there is some property that I can use or any workaround, to load about 70,000 data in 1 telerik mvc combobox.

Please advice. 

4 Answers, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 15 Apr 2011, 07:58 AM
Hello Barry,

You can refer to this page for an example what you can do.

http://thoughtfulcode.wordpress.com/2011/01/03/custom-jsonresult-class-for-asp-net-mvc-to-avoid-maxjsonlength-exceeded-exception/

However, we strongly discourage you to try to place 70,000 items in anything on a web page - the client performance penalty will surely be noticable, and also the usability of such a scenario is rather questionable at best.

A lot smarter approach is to filter server-side, depending on some client-set criteria and fetch only what is needed to the browser. This is demonstrated here:

http://demos.telerik.com/aspnet-mvc/combobox/ajaxloading

Greetings,
Dimo
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Barry
Top achievements
Rank 1
answered on 18 Apr 2011, 02:46 AM
Thanks Dimo.

I will clarify again with the user why they want to display the 70,000 records in the combobox.

Anyway, if they still persist, how can I apply the custom JsonResult Class in my telerik combobox?

I do not use Json explicitly so I think it is being used by the default telerik scripts. Please advice

My actual code is

 

 

<td>

 

<%

 

= Html.Telerik().ComboBoxFor(model => model.CompanyName)

 

 

.BindTo((

 

SelectList)ViewData["NameList"])%>

 

 

 

 

</td>

 

 

The ViewData["NameList"] contains 70,000 records

0
Dimo
Telerik team
answered on 18 Apr 2011, 09:34 AM
Hello Barry,

We did some tests on our side and our final recommendation is that you change your approach and don't try to display 70,000 items at the same time in any way.

- If you use a simple <select> element, it will work in all browsers, but the HTML output of the dropdown will be at least 3 MB, depending on the items' text length.

- If you use a Telerik MVC extension (ComboBox, DropDownList or AutoComplete), first of all, you must modify the source code by setting the MaxJsonLength property in Telerik.Web.MVC \ UI \ ClientSideObjectWriter.cs. After rebuilding the source code, the items' data will be serialized to the browser, however, you will witness various issues in different browsers, for example:

-- out-of-memory exceptions in Firefox 3 and IE6 - the dropdown will not open
-- inability to select items in Chrome
-- 5-10 seconds lag in all browsers before the dropdown opens each time
-- considerable lag (e.g. 60 seconds in IE9) before the dropdown opens for the first time - during that time the browser parses the serialized datasource and creates new elements in the DOM tree. There is a risk of complete browser hang
-- memory consumption spike when the dropdown is opened - e.g. about 150 MB in Chrome

I use a 2.66 GHz Quad-core CPU with 8GB RAM - you can imagine what will happen on a weaker regular user PC.

In such cases it is the developer's responsibility to create an application scenario, which is fast, responsive and usable, and which spares both server and client resources. You should convince your client that load on demand and server filtering should be used, as described in my previous reply.

Best wishes,
Dimo
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Barry
Top achievements
Rank 1
answered on 19 Apr 2011, 03:46 AM
Thanks Dimo for the very detailed response.

As you have adviced, we have decided to not load the 70000 data and we will be just utilizing the load on demand feature.

Thanks again!
Tags
ComboBox
Asked by
Barry
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Barry
Top achievements
Rank 1
Share this question
or