BoldSignEasily embed eSignatures in your .NET applications. Free sandbox with native SDK available.
@(Html.EJ().Grid<Customers>("RemoteBinding") .Datasource("odata/ODATACustomers/").ToolbarSettings(toolbar => { toolbar.ShowToolbar().ToolbarItems(items => { items.AddTool(ToolBarItems.Add); items.AddTool(ToolBarItems.Edit); items.AddTool(ToolBarItems.Delete); items.AddTool(ToolBarItems.ExcelExport); }); }).Mappers(map => map.ExportToExcelAction("Customers/ExcelAction")) .AllowPaging() .PageSettings(page => { page.PageSize(9); }) .Columns(col => { col.Field("A").HeaderText("Order ID").IsPrimaryKey(true).IsIdentity(true).TextAlign(TextAlign.Right).Width(75).Add(); col.Field("B").HeaderText("Name").Width(90).Add(); }).AllowFiltering().FilterSettings(filter => { filter.FilterType(FilterType.Excel); }).AllowSorting().IsResponsive(true) ) |
public void ExcelAction(string GridModel) { ExcelExport exp = new ExcelExport(); var DataSource = db.Customers.ToList(); GridProperties obj = ConvertGridObject(GridModel); exp.Export(obj, DataSource, "Export.xlsx", ExcelVersion.Excel2010,false, false, "flat-saffron"); } private GridProperties ConvertGridObject(string gridProperty) { JavaScriptSerializer serializer = new JavaScriptSerializer(); IEnumerable div = (IEnumerable)serializer.Deserialize(gridProperty, typeof(IEnumerable)); GridProperties gridProp = new GridProperties(); foreach (KeyValuePair<string, object> ds in div) { var property = gridProp.GetType().GetProperty(ds.Key, BindingFlags.Instance | BindingFlags.Public | BindingFlags.IgnoreCase); if (property != null) { Type type = property.PropertyType; string serialize = serializer.Serialize(ds.Value); object value = serializer.Deserialize(serialize, type); property.SetValue(gridProp, value, null); } } return gridProp; } |
Hi Xenon,
Thanks for contacting Syncfusion support.
We have analyzed your query and we have internally created a sample with OData and tried exporting it. It is exported correctly as expected also we were unable to reproduce the reported issue.
We request you to share more information on this issue. Please let us know, whether you were unable to get the ‘filtered record’ or it shows 'no records’ while exporting.
We need more information on the reported issue that you are facing with “OData exporting” along with the issue replication procedure and working scenario. We would appreciate if you provide more details like screenshot / video / error reproducing sample will be helpful for us to proceed further.
Regards,
Prasanna Kumar
public void ExportToExcel(string gridModel) { GridExcelExport gridExp = new GridExcelExport(); ExcelExport exp = new ExcelExport(); IEnumerable dataSource = DieuDongThietBiContext.GetAllEquipmentByDepartment(); //Return list of object. It the same with datasource in view. GridProperties obj = ConvertGridObject(gridModel); exp.Export(obj, dataSource, "Export.xlsx", ExcelVersion.Excel2010, false, false, "default-theme"); } |
Hi Xenon,
We tried with the attached sample and we can export with filtered records in excel. So, please confirm the following details.
1. In the attached screenshot, according to the call stack the issue is reproduced while performing sorting operation.
2. Ensure that you are able to get the data in the controller.
3. We suggest you to add a break point in the export function and ensure that you able to get the sorted columns in the obj.
Please find the screenshot:
4. Essential Studio version details.
For your convenience, we attached a video while exporting and please download the video from the following link
Link: http://www.syncfusion.com/downloads/support/forum/118880/ze/Video1157328958
Regards,
Prasanna Kumar N.S.V