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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Grid Not Loading DataSource on Export

Thread ID:





124118 May 18,2016 10:55 AM UTC May 26,2016 05:15 AM UTC ASP.NET MVC 3
Tags: Grid
Avi Segal
Asked On May 18, 2016 10:55 AM UTC

I am using version 13.40.58

When exporting to Excel  using the grid, the data does not get loaded & causes an error, it excludes the datasource.

Please advise.


Jayaprakash Kamaraj [Syncfusion]
Replied On May 19, 2016 03:29 PM UTC

Hi Avi, 

Thanks for contacting Syncfusion support. 

Query: When exporting to Excel  using the grid, the data does not get loaded & causes an error, it excludes the datasource. 

We suspect that you have passed the grid model dataSource to server side upon exporting. In such case, we need to handle the dataSource at server side else exception will be thrown. Please refer to the below code example. 

<script type="text/javascript"> 
   function databound(args){ 
        var grid = $('#FlatGrid').ejGrid('instance'); 
        grid.ignoreOnExport.splice(grid.ignoreOnExport.indexOf('dataSource'), 1); // here we will splice dataSource property in ignoreOnExport method 
public void ExportToExcel(string GridModel) 
            ExcelExport exp = new ExcelExport(); 
            GridProperties obj = ConvertGridObject(GridModel); 
            exp.Export(obj,(IEnumerable)(obj.DataSource), "Export.xlsx", ExcelVersion.Excel2010, false, false, "flat-saffron"); 
private GridProperties ConvertGridObject(string gridProperty) 
           foreach (KeyValuePair<string, object> ds in div) 
                if (ds.Key == "dataSource") 
                    string serialize = serializer.Serialize(ds.Value); 
                    gridProp.DataSource = serializer.Deserialize<List<OrdersView>>(serialize); // here we need to deserialize tha dataSource (OrdersView as Class name) 
            return gridProp; 

For your convenience we have created sample to splice the grid dataSource property on ignoreOnExport method then handle the grid model dataSource in server side. If the above is your scenario, we suggest you to deserialize the dataSource at server side as in the above code. 

If not, exception will occur when a column field is not defined in the Grid dataSource, it is obtained as null value and hence throws a null exception. Please refer to the following knowledgebase document for more information. 

If your scenario is different,  share the following information,                                                                           
1.       Screenshot of the stack trace of the exception obtained. 
2.       Full client and server-side code example. 
3.       Did you exporting DataTable? If, yes we have provided DataTable exporting support from v14.1.0.41 onwards. 
4.       Sample hosted link or replicate the issue in the following sample. 


Jayaprakash K. 

Avi Segal
Replied On May 25, 2016 09:06 AM UTC

Thank you - All working

Mani Sankar Durai [Syncfusion]
Replied On May 26, 2016 05:15 AM UTC

Hi Avi, 

Thanks for your feedback. 
We have happy to hear that your requirement is achieved.  
Manisankar Durai. 


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon