This is a migrated thread and some comments may be shown as answers.

excel export and CustomBinding

9 Answers 135 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Alan Mosley
Top achievements
Rank 1
Alan Mosley asked on 20 May 2015, 11:12 AM

I just tried the excel export with custom binding, of cause I knew it would not get all data with custom binding, it only gets the current page.

I can get the data myself if I could get the filter info, how to get filter info when using excel export?
Thanks

9 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 22 May 2015, 06:14 AM
Hello Alan,

The excel exporting will hit the Read() method of the grid's data source. If you set the AllPages option to true this will export all pages:

@(Html.Kendo().Grid()
             .Excel(excel => excel.AllPages(true))
)

Regards,
Atanas Korchev
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Alan Mosley
Top achievements
Rank 1
answered on 22 May 2015, 07:20 AM
I am using custom binding, so it only outputs the page that is visible.
0
Atanas Korchev
Telerik team
answered on 25 May 2015, 06:22 AM
Hi Alan,

If you return only one page then the grid can't export all pages. You should check what the PageSize property of the DataSourceRequest parameter is and return the same amount of items. The grid will set the PageSize to the total number of items when exporting all pages.

Regards,
Atanas Korchev
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Alan Mosley
Top achievements
Rank 1
answered on 25 May 2015, 10:02 AM
That's would mean returning and rendering thousands of records, and if the user wants to sort or filter them before exporting that would be quite a bit of overhead.
What I have done is save the DataSourceRequest in a session object and then use that in the export controller to get correct data, but I thought there would be a better way of getting that data in the export controller, eg: the export request sending filter and sort data to the controller. The workaround will do unless you can suggest a more elgant way of doing this, thanks
0
Atanas Korchev
Telerik team
answered on 25 May 2015, 11:55 AM
Hello Alan,

If you want to export all data you have to return it to the grid. If you want to apply some filter - you can distinguish the export read request by checking the PageSize of the DataSourceRequest parameter. 

Regards,
Atanas Korchev
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Alan Mosley
Top achievements
Rank 1
answered on 25 May 2015, 01:26 PM

sorry I don't follow you. what do you mean by "distinguish the export read
request"

 when exporting is the DataSourceRequest parameter sent to the server?

Thanks

0
Atanas Korchev
Telerik team
answered on 25 May 2015, 02:13 PM
Hi Alan,

Yes, the grid will make a Read request in the case of Excel export and set the PageSize to the total number of items if you have set AllPages to true

Regards,
Atanas Korchev
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Alan Mosley
Top achievements
Rank 1
answered on 25 May 2015, 05:35 PM
Just to make things clear, is the filter and sort info also sent? thanks
0
Alan Mosley
Top achievements
Rank 1
answered on 26 May 2015, 04:40 AM

Thanks, I am understanding better now, I did not realize that that both the read and export controllers were called, I was looking for DataSourceRequest object on export controller.

Thanks all seems to be working fine now

Tags
Grid
Asked by
Alan Mosley
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Alan Mosley
Top achievements
Rank 1
Share this question
or