private void cbExportElementType_SelectionChanged(object sender, Telerik.Windows.Controls.SelectionChangedEventArgs e) { if (e.AddedItems.Count > 0) { ExportElementOptions selectedOption = ExportElementOptionsInfo.Where(t => t.ExportElementType == (e.AddedItems[0] as ExportElementType).ExportElementTypeValue).FirstOrDefault(); this.rcpBackground.SelectedColor = selectedOption.ExportElementBackground; this.rcpForeground.SelectedColor = selectedOption.ExportElementForeground; this.rnudFontSize.Value = selectedOption.ExportElementFontSize; if (ExportFontFamilyInfo == null) { InitializeExportFontFamilyInfo(); } this.cbFontFamily.SelectedValue = ExportFontFamilyInfo.Where(t => t.ExportFontFamilyValue.Source == selectedOption.ExportElementFontFamily.Source).FirstOrDefault(); if (ExportFontWeightInfo == null) { InitializeExportFontWeightInfo(); } this.cbFontWeight.SelectedValue = ExportFontWeightInfo.Where(t => t.ExportFontWeightValue == selectedOption.ExportElementFontWeight).FirstOrDefault(); if (ExportTextAlignmentInfo == null) { InitializeExportTextAlignmentInfo(); } this.cbTextAllignment.SelectedValue = ExportTextAlignmentInfo.Where(t => t.ExportTextAlignmentValue == selectedOption.ExportElementTextAlignment).FirstOrDefault(); } }
/// <summary> /// Handles RadGridView Element Export in predefined prameterized details /// </summary> /// <param name="exportElement">GridViewElementExportingEventArgs - custom argument received in RadGridView Element_Exporting event</param> /// <param name="cellValueConverter">Function to convert cell values to customed values</param> /// <param name="headerCellValueConverter">Function to convert header cell values to customed values</param> /// <param name="isGroupFootersVisible">True to display group footers in export</param> /// <param name="hideColumnIndex">List of column indexes to be hide in export</param> /// <param name="aggregatedColumnIndex">aggregated column indexes</param> public static void ElementExporting(GridViewElementExportingEventArgs exportElement, Func <object> cellValueConverter = null, Func <object> headerCellValueConverter = null, bool isGroupFootersVisible = true , List <int> hideColumnIndex = null, List <int> aggregatedColumnIndex = null) { ExportElementOptions element = ExportElementOptions.Where(t => t.ExportElementType == exportElement.Element).FirstOrDefault(); if (element != null) { exportElement.Background = element.ExportElementBackground; exportElement.Foreground = element.ExportElementForeground; exportElement.FontFamily = element.ExportElementFontFamily; exportElement.FontSize = element.ExportElementFontSize; exportElement.Height = element.ExportElementFontSize + 5; exportElement.Width = 100; exportElement.VerticalAlignment = VerticalAlignment.Center; exportElement.FontWeight = element.ExportElementFontWeight; exportElement.TextAlignment = element.ExportElementTextAlignment; } if (hideColumnIndex != null) { GridViewDataColumn column = exportElement.Context as GridViewDataColumn; if (column != null) { if (exportElement.Element == ExportElement.Cell || exportElement.Element == ExportElement.FooterCell || exportElement.Element == ExportElement.GroupFooterCell || exportElement.Element == ExportElement.GroupHeaderCell || exportElement.Element == ExportElement.GroupIndentCell || exportElement.Element == ExportElement.HeaderCell) { if (hideColumnIndex.Contains(column.DisplayIndex)) { exportElement.Cancel = true; } } } } if (exportElement.Element == ExportElement.HeaderCell) { if (headerCellValueConverter != null) { exportElement.Value = headerCellValueConverter(); } } if (exportElement.Element == ExportElement.GroupFooterRow || exportElement.Element == ExportElement.GroupFooterCell) { if (isGroupFootersVisible == false) { exportElement.Cancel = true; return; } } if (exportElement.Element == ExportElement.Cell) { if (cellValueConverter != null) { exportElement.Value = cellValueConverter(); } } if (exportElement.Element == ExportElement.Row) { if (cellValueConverter != null) { exportElement.Value = cellValueConverter(); } } if (exportElement.Element == ExportElement.FooterCell) { if (cellValueConverter != null) { exportElement.Value = cellValueConverter(); } } else if (exportElement.Element == ExportElement.GroupFooterCell) { GridViewDataColumn column = exportElement.Context as GridViewDataColumn; QueryableCollectionViewGroup qcvGroup = exportElement.Value as QueryableCollectionViewGroup; if (column != null && qcvGroup != null && column.AggregateFunctions.Count > 0) { exportElement.Value = GetAggregates(qcvGroup, column); } else { exportElement.Value = ""; } } }