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

[Solved] Exporting RadGrid with custom paging?

7 Answers 316 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Adam Hubble
Top achievements
Rank 1
Adam Hubble asked on 10 Feb 2009, 03:05 PM
Hi, I would like to allow users to export all data from radgrid even if only 1 page is showing. So for example the grid may show 10 of 100 items. I would like users to be able to export all rows, not just the first 10 on a button click. This is a problem as I'm using custom paging so radgrid's ignorepaging does not help.

Does anybody know how I should go about doing this? I assume one way would be to increase the pagesize to the total number of rows available just before the export then set it back afterwards, but I'm not sure how to do this. 

Thanks!

7 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 10 Feb 2009, 03:37 PM
Hello Matt,

You can disable paging or set the page size to total number of items temporary to avoid this.

Regards,
Vlad
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Adam Hubble
Top achievements
Rank 1
answered on 10 Feb 2009, 03:43 PM
Hi Vlad, I'm not sure how disabling paging would work.  How can I access the total number of records on a button click?

Thanks
Matt
0
Vlad
Telerik team
answered on 10 Feb 2009, 03:56 PM
Hi Matt,

If this is custom paging you should have something in VirtualItemCount.

Best wishes,
Vlad
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Adam Hubble
Top achievements
Rank 1
answered on 12 Feb 2009, 02:28 PM
Hi Vlad, this does not work, VirtualItemCount always seems to be '0'. I'm using an ObjectDataSource to get the custom paged data. Is there another way I can get at the total number of records available to the grid? I have advanced pager enabled and RadGrid is showing 1-10 out of 300 records so it does 'know' how many are available, but virtualitemcount appears to be 0 when i access it on a button click..

Thanks
0
Rosen
Telerik team
answered on 16 Feb 2009, 10:06 AM
Hi Matt Davis,

Can you please paste you code or send it attached to a formal support ticket?

Sincerely yours,
Rosen
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Brian
Top achievements
Rank 1
answered on 31 Dec 2009, 06:32 PM
I'm having the same issue.  Did Telerik ever provide a solution to this problem?  If so, please post it for the rest of us on the forum.  Thanks!
0
Adam Hubble
Top achievements
Rank 1
answered on 04 Jan 2010, 09:58 AM
Hi Brian, the key issue seemed to be the need to call RadGrid's ReBind() method at the right point in the code to make it apply the page size changes required. I have bolded this below.

 Here is the code I used in vb.net with some comments, a C# translation is very easy.

Hope this helps,
Matt

----------------------------------------------


Protected
Sub exprtPdfBtn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles exprtPdfBtn.Click

 

 


'switch is used to determine if the user selected "export all records (value=0)" or "export just this page" from a radiobuttonlist
'if selected value=0 then we set radgrids pagesize to virtualitemcount (I used custom paging objectdatasource)

Select
Case optionListA.SelectedValue

 

 

Case 0

 

productsRadGrid.PageSize = productsRadGrid.MasterTableView.VirtualItemCount

 

End Select

 

 

 

productsRadGrid.ExportSettings.IgnorePaging = False

 

productsRadGrid.Rebind()

productsRadGrid.ExportSettings.ExportOnlyData = True

productsRadGrid.MasterTableView.ExportToPdf()

 

End Sub

 


 

 

 

 

Tags
Grid
Asked by
Adam Hubble
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Adam Hubble
Top achievements
Rank 1
Rosen
Telerik team
Brian
Top achievements
Rank 1
Share this question
or