I'm trying to export ALL the records using GridViewSpreadStreamExport. Here is the snippet.
But the excel sheet is only showing the records displayed in the grid (which is 20). I have a RadDataPager and the is set to 20 with source ElementName as RadGridView.
How do I export all data in the Logs ItemSource of the grid?
8 Answers, 1 is accepted
I have changed the above code to include a little logic that controls the PageSize before and after the SpreadStreamExport as below.
But the first time button click returns the records in the grid (20 rows), not all records. H, the 2nd button click returns all the records in . What am missing Why is the export not exporting all records in the first attempt as set the PageSize to DO I need to fire event manually? I could not find the event for RadDataPager.
As you've correctly figured out, you need to set the PageSize of the RadDataPager to 0 prior to exporting the data to have all records exported rather than only the current page.
As the export process is asynchronous, however, returning the original PageSize should happen after the process is done, namely in the AsyncExportCompleted event handler:
I've attached a sample project where doing so results in all the records being exported for your reference.
Please let me know whether you manage to achieve the same result.
Your attached sample runs excellent. However, as soon as I added the AsyncExportCompleted event handler (line 23, 34 onwards), the screen just freezes. And the control never steps in the AsyncExportCompleted event.
I compared my code with the sample code and they look the same. Any idea what could cause this behavior?
I'm afraid I'm unable to pinpoint a cause for this behavior by only looking at the code you provided. Indeed, the two code snippets seem identical.
Would you find it possible to isolate the behavior you observe in a small sample project so that I can investigate it at my end and assist you further? Please note that as the forum system does not accept attachments other than images, you will either need to open a new support ticket through an account with an active license, or upload the project in a storage provider of your choice.
Thank you in advance for your cooperation on the matter.
I think I figured the reason why the UI hangs once clicked on export. To reproduce this, In the sample project you provided in the earlier post, change the below likes from
Changing the RowDefinition from * to Auto hangs the UI and gets struck some kind of loop.
Indeed, this explains the hang as when the RadGridView control is placed in a row definition with height Auto it is measured with infinity, which breaks the control's UI virtualization. Once the PageSize is set to 0, all rows will be attempted to be drawn which will block the UI for a certain period, depending on the number of items in the bound collection.
The solution would be to place the control in a panel which does not measure it with infinity. Please let me know whether you find this possible.