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

Ajax Grid Serialization Bug: Big Data

2 Answers 509 Views
Grid
This is a migrated thread and some comments may be shown as answers.
BigzampanoXXl
Top achievements
Rank 1
BigzampanoXXl asked on 26 Jun 2013, 02:10 PM
Hello,

I have a simple Ajax Kendo Grid which looks the following:

@(Html.Kendo().Grid(m)
        .Name(gridName)
        .BindTo(m)
        .ToolBar(commands => commands.Create().Text(newButtonText))
        .Events(e => e.Edit("onGridCellEdit" + gridName))
        .DataSource(dataSource => dataSource.Ajax().Events(ev => ev.Change("onDataSourceChange" + gridName))
        .Model(model =>
        {
            model.Id(p => p.ID);
            model.Field(p => p.Function).DefaultValue((KeyValueObjectViewModel)ViewData[SAPController.GRID_DDL_PROPERTY_FUNCTION + "_Default"]);
            model.Field(p => p.SAPClientEmpty).DefaultValue((KeyValueObjectViewModel)ViewData[SAPController.GRID_DDL_PROPERTY_SAP_CLIENT_EMPTY + "_Default"]);
            model.Field(p => p.Person).DefaultValue(new ResultEntryViewModel(true, false));
        }).ServerOperation(false)
        )
        .Columns(columns =>
        {
            columns.Bound(p => p.Function).ClientTemplate("#=Function.Name#").Width(200).Title(Strings.ColumnFunction);
            columns.Bound(p => p.SAPClientEmpty).ClientTemplate("#=SAPClientEmpty.Name#").Width(200).Title(Strings.ColumnSAPClient);
            columns.Bound(p => p.Person).ClientTemplate("#=Person.Name#").Title(Strings.ColumnPerson);
            columns.Template(@<text></text>).Width(20).ClientTemplate(TemplateConstants.GRID_CLIENTTEMPLATE_DELETE_COLUMN);
        })
        .Editable(editing => editing.Mode(GridEditMode.InCell).CreateAt(GridInsertRowPosition.Bottom))
    )
The grid renders fine without any problems when the amount of data is low.

Now if I have a lot of data in the grid (the table in the database has a few thousand rows), I get an error from Kendo when serializing the grid data:

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

It seems that the JavaScriptSerializer that Kendo uses does not use the maximum valid json length and instead uses the default length. I have set the following entries in my web.config, which does not make any differences:

<system.web.extensions>
        <scripting>
            <webServices>
                <jsonSerialization maxJsonLength="2147483647"/>
            </webServices>
        </scripting>
</system.web.extensions>
So I assume the JavaScriptSerializer you use for the Kendo Grid simply ignores this setting. What about setting the MaxJsonLength property  for the JavaScriptSerializer hardcoded to its maximum value:

JavaScriptSerializer ser = new JavaScriptSerializer();
ser.MaxJsonLength = Int32.MaxValue;
// TODO: Do the Kendo Grid serialization ...
Would that be possible for you do set that property to its max value? 
Any other ideas how I can use the grid with big data?
I know, I could use paging, but the customer does not want a paged grid ...

Please help, thanks!
Greets

PS: I have attached an image of the exact error message including the full callstack.







2 Answers, 1 is accepted

Sort by
0
Accepted
Atanas Korchev
Telerik team
answered on 26 Jun 2013, 02:44 PM
Hi Dietmar,

 Setting maxJsonLength doesn't really work in ASP.NET MVC applications. A possible workaround of this ASP.NET MVC limitation is available in our troubleshooting help article: http://docs.kendoui.com/getting-started/using-kendo-with/aspnet-mvc/helpers/grid/troubleshooting#error-during-serialization-or-deserialization-using-the-json-javascriptserializer

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
BigzampanoXXl
Top achievements
Rank 1
answered on 26 Jun 2013, 03:03 PM
Thanks for fast reply.

I will create a new ViewModel which  is binded to the grid, that has a minimum number of properties to keep the Json-String as short as possible.

Greets
Tags
Grid
Asked by
BigzampanoXXl
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
BigzampanoXXl
Top achievements
Rank 1
Share this question
or