Hi Manolo,
Thanks for using Syncfusion products.
Query 1: I want populate a grid and I get this error.
The issue “Error during serialization or deserialization with JavaScriptSerializer of JSON” can be resolved by using WebMethodAdaptor, which is used for performing server side operations.
Please refer the below KB link for more clarification about WebMethodAdaptor.
KB Link: http://www.syncfusion.com/kb/4300/server-side-api-for-datamanager-operations
Query 2: When I load the grid, it's always with loading icon and If I've 3 or 4 or more grids, I need rewrite the script loadHandler in each page
With the reference of the forum (#117447), we found that the response was provided on October 23, 2014, whereas we did not have support for BatchURL at that time. So that we have extended the adaptor in load event of the grid and bind the data source from the server side. Now in the latest version, the below code is not necessary.
var adaptor = new ej.UrlAdaptor().extend({ processResponse: function (data, ds, query, xhr, request, changes) { return data.d; } }); function loadHandler(args) { args.model.dataSource.dataSource.batchUrl = "Default.aspx/Update" args.model.dataSource.adaptor = new adaptor(); public static object Data(int skip, int take) { var DataSource = OrderRepository.GetAllRecords(); DataResult ds = new DataResult(); ds.result=DataSource.Skip(skip).Take(take); ds.count= ds.count = DataSource.Count(); return ds; |
Instead of the above code we can use the WebMethodAdaptor for performing on demand paging as follows.
<ej:Grid ID="EmployeesGrid" runat="server" Width="1500px" AllowPaging="true" > [WebMethod] [ScriptMethod(ResponseFormat = ResponseFormat.Json)] public static object Data(Syncfusion.JavaScript.DataManager value) { IEnumerable Data = OrderRepository.GetAllRecords(); int count = Data.AsQueryable().Count(); Syncfusion.JavaScript.DataSources.DataOperations operation = new Syncfusion.JavaScript.DataSources.DataOperations(); Data = operation.Execute(Data, value); return new { result = Data, count = count }; |