We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Error during serialization or deserialization using the JSON JavaScriptSerializer

Dear All

I have prepared a small demo to show the errors I get.

I have two questions:

1. How can I prevent the above error message in the supjetc for huge data?
2. How can I prevent a whole reload of the page, so that only the grid is refreshed with the data after presing the button

Thanks for helping.

Martin 

Attachment: Demo_4c76271d.zip

3 Replies

MF Mohammed Farook J Syncfusion Team September 5, 2016 05:34 AM UTC

Hi Martin, 

Thanks for contacting Syncfusion Supports. 

Please find the response.              
Query 
Response 
1.        How can I prevent the above error message in the supjetc for huge data? 
To avoid the issue please find the steps. 
 
i)                    we have used the default MaxJsonLength value (2097152 characters, which is equivalent to 4 MB of Unicode string data) of the JavaScriptSerializer which is a fixed universal standard length for serializing the data. 
Please find Custom datasource serializer class will be as follows. 
 
public class DMSerial : IDataSourceSerializer  
{ 
        public string Serialize(object obj) 
        { 
            var str = Newtonsoft.Json.JsonConvert.SerializeObject(obj); 
            return str; 
        } 
    } 
 
 
ii)                   To use ej.Webmethod Adaptor. Please find the link. 
 
  
 
2.       How can I prevent a whole reload of the page, so that only the grid is refreshed with the data after presing the button 
 
if we are using ej.WebMethod Adaptor  , we need to handle sorting, filtering or paging in server side. So grid automatically post back occurred. this is default behavior 
 


Regards, 
J.Mohammed Farook 



MS Martin Sickel September 5, 2016 07:52 AM UTC

Hi J.Mohammed

Thanks for the answer.

I understand that I have to use Datamanger to get an expected result.

If I set now the Dataadpater with the different URL sets like " URL="default.aspx/Data" ", " UpdateURL="default.aspx/update" " etc..
is there a way to execute UpdateURL with a click on a "Custom Button" like

<ej:Button ID="btnInsert" Type="Button"  runat="server" Text="Update" OnClick="btnInsert_Click" ></ej:Button> 

without refreshing the whole page? 




KK Karthick Kuppusamy Syncfusion Team September 7, 2016 01:24 PM UTC

Hi Martin, 

We have analyzed the requirement and we can bind the url data  to the ejGrid using the custom button. 

Please find the code example. 

<ej:Button ID="btnInsert" Type="Button" runat="server" Text="Update" ClientSideOnClick="btnclick" ></ej:Button>  
    
     <ej:Grid ID="Grid" runat="server" AllowPaging="True" AllowTextWrap="True" 
                    ShowStackedHeader="True" 
                    AllowScrolling="true" 
                   AllowFiltering="true" 
                   AllowResizeToFit="true" 
                    Selectiontype="Single"  
       > 
        <Columns> 
            . 
            . 
        </Columns> 
    </ej:Grid> 
   <script type="text/javascript"> 
       function btnclick(e) { 
          var data = ej.DataManager({ 
               url: "/Default.aspx/DataSource", 
               adaptor: new ej.WebMethodAdaptor() 
           }) 
           var query = new ej.Query(); 
           var execute = data.executeQuery(query)  
                   .done(function (e) { 
                       var data = e.result; 
                       var obj = $("#MainContent_Grid").ejGrid("instance"); 
                       obj.dataSource(data.result);//bind the data for grid 
                   }); 
       } 
 
</script> 


Please find the UG Link. 

For your reference we have created a sample based on your requirement and same it can be downloaded from the following location. 

Regards, 
K.Karthick. 


Loader.
Up arrow icon