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

[Solved] Multiple data rows result problem

4 Answers 162 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
David
Top achievements
Rank 1
David asked on 31 Jul 2012, 11:59 AM
Hello,

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...

There is code from my Controller:
[GridAction, POST("GridData")]
public ActionResult _Index()
{
    var data = GetExclusionsDataCollection();
 
    return View(new GridModel { Data = data });
}

Thanks,
David

4 Answers, 1 is accepted

Sort by
0
David
Top achievements
Rank 1
answered on 06 Aug 2012, 08:00 AM
Hi all,

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...

DI.Current.Register<IGridActionResultFactory>(() => new MyCustomGridActionResultFactory());

This line causes ovveride default Telerik functionality and active your custom Json result...

-David
0
Tom
Top achievements
Rank 1
answered on 30 Aug 2012, 06:20 PM
Hi Davis, 

Can you elaborate you solution a little bit? I have a same issue as yours. after I  return an  my own ActionResult. the sorting and filter doesn't work anymore. 

thanks  a lot 
0
David
Top achievements
Rank 1
answered on 31 Aug 2012, 07:24 AM
Hello Tom,

It's very important have "GridAction" atribute on your Controller action and before you serialize collection of data cast the collection as GridModel. Like this Example:

[GridAction, POST("Grid_Data")]
public ActionResult _Index(string searchText, bool returnActualOnly, bool showHistory, bool DisableFilterByAdminUnit)
{
    var data = GetExclusionsDataCollection();
 
    return Json(new GridModel { Data = data });
}

When you Convert your collection to GridModel, Telerik solves ordering and filtering...

-David
0
Tom
Top achievements
Rank 1
answered on 31 Aug 2012, 07:58 AM
Hi David,

thanks very much for your reply. the problem is that I can't just  "return Json(new GridModel { Data = data }); " because 
I will have this error"Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property
" again. how can I solve the serialization length limitation issue and keep the sorting work at the same time? 
can you post a piece of your code?
thanks very much 
 
Tags
Grid
Asked by
David
Top achievements
Rank 1
Answers by
David
Top achievements
Rank 1
Tom
Top achievements
Rank 1
Share this question
or