I am trying to export only the selected items from a grid. But it exports everything. Here is grid, which is dynamically defined.
Here is the export button click, which works for exporting everything, but it does not handle selected items.
Here is the dynamic creation of the select column. The other columns are created in a similar way.
Any idea why it is not only doing the selected items?
Thanks!
<telerik:RadGrid ID="DisplayDataGrid" runat="server" AutoGenerateColumns="False" AllowMultiRowSelection="True" AllowSorting="True" AllowPaging="True" PageSize="6" OnNeedDataSource="Grid_NeedDataSource" OnItemCreated="ImageryGrid_ItemCreated" ShowStatusBar="true" Width="100%" GridLines="None" Skin="Hay" ItemStyle-Font-Size="7pt" AlternatingItemStyle-Font-Size="7pt"> <ClientSettings EnableRowHoverStyle="true"> <Scrolling AllowScroll="True" ScrollHeight="230px" UseStaticHeaders="false" /> <Selecting AllowRowSelect="true" /> </ClientSettings> <ExportSettings IgnorePaging="true" OpenInNewWindow="true" FileName="ImageryExcel" ExportOnlyData="true" /> <MasterTableView HeaderStyle-Wrap="false" TableLayout="Fixed"> <PagerStyle AlwaysVisible="True" FirstPageToolTip="" LastPageToolTip="" NextPagesToolTip="" PrevPagesToolTip="" PrevPageToolTip="" NextPageToolTip="" /> </MasterTableView> </telerik:RadGrid>Here is the export button click, which works for exporting everything, but it does not handle selected items.
Public Sub ButtonExcel_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ButtonExcelIMG.Click AssignGridDataSource() DisplayDataGrid.DataBind() DisplayDataGrid.MasterTableView.Columns.FindByUniqueName("ClientSelectColumn").Visible = False DisplayDataGrid.ExportSettings.ExportOnlyData = True DisplayDataGrid.ExportSettings.OpenInNewWindow = True If DisplayDataGrid.SelectedItems.Count > 0 Then For Each dataItem As GridDataItem In DisplayDataGrid.MasterTableView.Items ' If dataItem.Selected Then ' DisplayDataGrid.MasterTableView. ' End If dataItem.Visible = dataItem.Selected dataItem.Enabled = dataItem.Selected dataItem.Display = dataItem.Selected Next End If 'Export to Excel DisplayDataGrid.MasterTableView.ExportToExcel() End SubHere is the dynamic creation of the select column. The other columns are created in a similar way.
DisplayDataGrid.Columns.Clear()Dim tcolumn As GridHyperLinkColumn = New GridHyperLinkColumnDim clientGrid As GridClientSelectColumn = New GridClientSelectColumn' CheckboxclientGrid.UniqueName = "ClientSelectColumn"clientGrid.HeaderStyle.Width = Unit.Pixel(25)clientGrid.ItemStyle.ForeColor = Color.RoyalBlueclientGrid.ItemStyle.HorizontalAlign = HorizontalAlign.CenterclientGrid.ItemStyle.Width = Unit.Pixel(25)DisplayDataGrid.Columns.Add(clientGrid)Any idea why it is not only doing the selected items?
Thanks!