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

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

3 Answers 969 Views
AutoComplete
This is a migrated thread and some comments may be shown as answers.
Jun
Top achievements
Rank 1
Jun asked on 11 Dec 2013, 01:59 PM
I read this Page.
( http://stackoverflow.com/questions/1151987/can-i-set-an-unlimited-length-for-maxjsonlength-in-web-config
 http://docs.kendoui.com/getting-started/using-kendo-with/aspnet-mvc/helpers/autocomplete/overview)

My Test Source: 
vs2012 , AdventureWorks2012Db, Person Table, Ef5,  KendoUIMvcApplication.
 
@(Html.Kendo().AutoComplete()
   .Name("test") //The name of the autocomplete is mandatory. It specifies the "id" attribute of the widget.
   .DataTextField("FirstName") //Specifies which property of the Product to be used by the autocomplete.))
   .BindTo(Model)   //Pass the list of Products to the autocomplete.
   .Filter("contains") //Define the type of the filter, which autocomplete will use.
 )



3 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 12 Dec 2013, 09:16 AM
Hi,

You can try the code from here.

Regards,
Atanas Korchev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
John
Top achievements
Rank 1
answered on 29 Dec 2015, 05:51 AM

Hi Atanas,

You mentioned 3 solutions:

1, Enable paging by calling the Pageable method
2, Use a View Model to serialize only the required properties of your model.
3, Manually serialize the DataSourceResult

 

For the first one, for I am using a chart, which is not pageable, I think?

The second one, do you mean pass as lease properties of the model as possible, to reduce the data to process? I will do this.

 The source code of the third solution is :

public ActionResult Read([DataSourceRequest] DataSourceRequest request){var data = GetData();var serializer = new JavaScriptSerializer();var result = new ContentResult(); serializer.MaxJsonLength = Int32.MaxValue; // Whatever max length you want here result.Content = serializer.Serialize(data.ToDataSourceResult(request)); result.ContentType = "application/json";return result;}

But I must return a view result to the view page, not a json format one. I tried the solution, the asp.net mvc view only display the data in json, not page.

 

Is there a solution for the root cause, not a workground?

 

Thank you.

 

 

0
Georgi Krustev
Telerik team
answered on 04 Jan 2016, 09:12 AM
Hello John,

The original question is related to the AutoComplete widget and the error you are using is related to the default maxvalue defined by the ASP.NET MVC framework. That being said, the solution provided by my colleague should be sufficient.

As to the additional comments, the Chart widgets has a navigator option that will allow you to reduce the visualized data: or you can pan/zoom the chart or selection:
In general, you can pass additional values to the View, filter the source and still return a View result. This is not related to Kendo UI / UI for ASP.NET MVC widget by any means, but rather is general ASP.NET MVC knowledge. I would suggest you accomplish your goal without the Kendo UI widgets and once this is done, to include them. I am sure that they will work as expected when JavaScriptSerializer works properly.

Regards,
Georgi Krustev
Telerik
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 Feedback Portal and vote to affect the priority of the items
Tags
AutoComplete
Asked by
Jun
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
John
Top achievements
Rank 1
Georgi Krustev
Telerik team
Share this question
or