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
close icon

Html.EJ().Grid excel filter and export error with ForeignKeyField

I have a problem with Html.EJ().Grid control, when i have a column with ForeignKeyField and i use the filter '.FilterType(FilterType.Excel)', so when i try to run the filter for that column i get a Javascript runtime error as i show in the picture ExcelFilterError.jpg in the attachment, a different columns filters well. Another issue is when i try to to export to an excel file which include  a column with ForeignKeyField i get an error 'object reference not set to an instance of an object.', if i comment out that column then it exports without issue.

Attachment: Errors_9d9b7dbb.rar

1 Reply

GV Gowthami V Syncfusion Team February 25, 2016 12:32 PM UTC

Hi bniasoff,

Thanks for using Syncfusion products.

Query 1:  i use the filter '.FilterType(FilterType.Excel)', so when i try to run the filter for that column i get a Javascript runtime error

We have analyzed your issue and we are unable to reproduce the issue.

Please provide below details to reproduce the issue.

1.     Share the code example of grid rendering code.

2.     Reproduce the reported issue in the below sample.

3.     Share the product version details.

The provided information will help to analyze  the issue and provide you the response as early as possible.

Query 2: when i try to to export to an excel file which include  a column with ForeignKeyField i get an error 'object reference not set to an instance of an object.',

We can achieve your requirement “Exporting the grid with Foreignkey field” by set the DataSource for the foreignkey column externally in server side.

Refer to the below code example,

public void ExportToExcel(string GridModel)
        {
. . . .

obj.Columns[2].DataSource = new DataClasses1DataContext().Employees.ToList();

            exp.Export(obj, DataSource, "Export.xlsx", ExcelVersion.Excel2010, false, false, "flat-saffron");
        }


For your convenience we have created a sample and the same can be downloaded from the following link,

http://www.syncfusion.com/downloads/support/directtrac/123196/MVCAPP~31101534944.ZIP

Regards,

Gowthami V.

Loader.
Live Chat Icon For mobile
Up arrow icon