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

Batch Editing with Server Operation False leads to max JSON length being exceeded

1 Answer 142 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Scott
Top achievements
Rank 1
Scott asked on 14 Dec 2018, 04:12 PM

I am following the directions for batch editing mode here:
https://demos.telerik.com/aspnet-mvc/grid/editing

When I disable server operation, I assume I am getting a LOT of records back from the database (50K+) and this is causing the following error: Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property.

How can I use ServerOperation for Paging/Sorting/Filtering functionality, but still use Batch with InCell editing mode?

Controller Code:

public ActionResult Contacts_Read([DataSourceRequest]DataSourceRequest request)
       {
     
           var dbcontext = new CRMDataModel2();
           IQueryable<vw_CRM_GetCompanyContacts> contacts = dbcontext.vw_CRM_GetCompanyContacts;
 
       
           DataSourceResult result = contacts.ToDataSourceResult(request, contact => new {
               Comp_Secterr = contact.Comp_SecTerr,
               PersonLinkId = contact.PersonLinkId,
               Office = contact.Office,
               Company = contact.Company,
               Year = contact.Year,
               Branch = contact.Branch,
               Supervisor = contact.Supervisor,
               AccountManager = contact.AccountManager,
               Contact = contact.Contact,
               Role = contact.Role,
               NPS = (bool)contact.NPS,
               Statement = (bool)contact.Statement,
               Invoices = (bool)contact.Invoices,
               FieldReport = (bool)contact.FieldReport,
               RainContact = (bool)contact.RainContact,
           });
 
           return Json(result);
       }
 
View Code:
//grid is set to incell editing
 .Edtable(editable => editable.Mode(GridEditMode.InCell))
 
 //data source is set to server operation false, batch true
DataSource(dataSource =>
            dataSource.Ajax()
            .ServerOperation(false)
            .Batch(true)
            .Read(read => read.Action("Contacts_Read", "ContactMaintenance"))
            .Update(update => update.Action("Contacts_Update", "ContactMaintenance"))
            .Destroy(destroy => destroy.Action("Contacts_Destroy", "ContactMaintenance"))
//...omitted for brevity

1 Answer, 1 is accepted

Sort by
0
Georgi
Telerik team
answered on 18 Dec 2018, 09:00 AM
Hello Scott,

The maximal size of a JSON is predefined out of the box and could be controlled by the MaxJsonLength property. However, if the max value is reached it is recommended to optimize the data that is returned to the client. If some of the fields in the data are not used by the client-side components consider no including these fields in the response. This way the data returned from the server would be less. Additionally that would improve performance as the response from the server will be returned faster.


Regards,
Georgi
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Grid
Asked by
Scott
Top achievements
Rank 1
Answers by
Georgi
Telerik team
Share this question
or