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.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Export to Excel does not take filters into account

Thread ID:

Created:

Updated:

Platform:

Replies:

114343 Nov 13,2013 11:03 PM UTC Feb 24,2018 03:38 PM UTC ASP.NET MVC (Classic) 2
loading
Tags: Grid
Bas Kroes
Asked On November 13, 2013 11:03 PM UTC

Hi,

I have an MVC4 page with the Syncfusion Grid and some filters around the grid (ListBox). These filters work perfect when using a pager (I declared an OnBeginAction where I store all current filter values in args.data). 

But the default Export to Excel button is not able to do this. It can respond to a OnToolbarClickEvent. But this doesn't give me access to args.data. 

Is there a workaround for this?

Sarath Kumar P [Syncfusion]
Replied On November 21, 2013 12:35 PM UTC

Hi Bas,

 

Thanks for using Syncfusion products.

 

We would like to let you know that in toolbar click event for excel check the condition  if (args._currentItemIndex == 0) then save the value in a variable and append the variable to the Excel form. In ExportToExcel action find the appended value in FormCollection  fc variable.

 

Please refer the below code snippets for your reference.

 

[controller.cs]

public ActionResult ExportToExcel(PagingParams args, FormCollection fc)  //find the value in  fc->base->All Keys.

 

{

var data = OrderRepository.GetAllRecords().Take(200).ToList();

return data.GridExportToExcel<MvcApplication627.Models.Student>("GridExcel.xlsx", ExcelVersion.Excel2007, args.ExportOption);

}

 

 

[view.cshtml]

 

<script type="text/javascript" language="javascript">

function ToolbarClick(sender, args) {

if (args._currentItemIndex == 0) {

var excel = "<input type='hidden' name='10000' id='excel'/>";

$("#GenericListGrid_exportExcel").append(excel);

}

}

 

</script>

 

Please refer our sample from the below link for your reference.

 

Link-Export.zip

 

Please let us know if you need further assistance.

 

Regards,

P.Sarathkumar.

 


Faizan Haider
Replied On February 24, 2018 03:38 PM UTC

Yes

CONFIRMATION

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.

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

;