This was working this way in 2017 then we changer it so all rows are affected. Bot modes should be supported.
Add a new property AllowSelection/EnableSelection in order to control whether the use can select a cell/row. Workaround: Private Sub RadForm1_Load(sender As Object, e As EventArgs) Handles MyBase.Load Me.ProductsTableAdapter.Fill(Me.NwindDataSet.Products) Me.RadGridView1.CurrentRow = Nothing AddHandler Me.RadGridView1.SelectionChanging, AddressOf Grid_SelectionChanging AddHandler Me.RadGridView1.CurrentRowChanging, AddressOf Grid_CurrentRowChanging End Sub Private Sub Grid_SelectionChanging(sender As Object, e As Telerik.WinControls.UI.GridViewSelectionCancelEventArgs) e.Cancel = True End Sub Private Sub Grid_CurrentRowChanging(sender As Object, e As Telerik.WinControls.UI.CurrentRowChangingEventArgs) e.Cancel = True End Sub
To reproduce: public RadForm1() { InitializeComponent(); this.radGridView1.EnableFiltering = true; this.radGridView1.ShowHeaderCellButtons = true; this.radGridView1.FilterPopupRequired += radGridView1_FilterPopupRequired; } private void radGridView1_FilterPopupRequired(object sender, Telerik.WinControls.UI.FilterPopupRequiredEventArgs e) { e.FilterPopup.PopupOpening -= FilterPopup_PopupOpening; e.FilterPopup.PopupOpening += FilterPopup_PopupOpening; } private void FilterPopup_PopupOpening(object sender, CancelEventArgs args) { args.Cancel = true; } Workaround: either set the ShowHeaderCellButtons property to false or closed the popup immediately after it is opened. private void radGridView1_FilterPopupRequired(object sender, Telerik.WinControls.UI.FilterPopupRequiredEventArgs e) { e.FilterPopup.PopupOpening -= FilterPopup_PopupOpening; e.FilterPopup.PopupOpening += FilterPopup_PopupOpening; } private void FilterPopup_PopupOpening(object sender, CancelEventArgs args) { RadListFilterPopup popup = sender as RadListFilterPopup; popup.PopupOpened -= popup_PopupOpened; popup.PopupOpened += popup_PopupOpened; } private void popup_PopupOpened(object sender, EventArgs args) { RadListFilterPopup popup = sender as RadListFilterPopup; popup.ClosePopup(RadPopupCloseReason.Mouse); }
We'd like to see the ability to enable a search/filter function for column chooser. One of our applications that uses the RadGridView has dozens of columns, most hidden by default. Our users would like the ability to type in part of a column name and have the column chooser filter on it.
The CustomSorting event should manipulate the pinned rows as well. Thus, the user will be allowed to control the sort order of the pinned rows within the pinned container.
Workaround: handle the GridViewPdfExport.CellFormatting event and apply the column`s format string Public Class Form1 Sub New() InitializeComponent() Me.RadGridView1.DataSource = Me.GetData() Me.RadGridView1.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill Dim decimalColumn = DirectCast(Me.RadGridView1.Columns("Money"), GridViewDecimalColumn) decimalColumn.DecimalPlaces = 0 decimalColumn.FormatString = "{0:C0}" Dim dateTimeColumn = DirectCast(Me.RadGridView1.Columns("Date"), GridViewDateTimeColumn) dateTimeColumn.FormatString = "{0:D}" End Sub Private Function GetData() As Object Dim dataTable As New DataTable() dataTable.Columns.Add("Id", GetType(Integer)) dataTable.Columns.Add("Name", GetType(String)) dataTable.Columns.Add("Money", GetType(Decimal)) dataTable.Columns.Add("Date", GetType(DateTime)) For i As Integer = 0 To 999 dataTable.Rows.Add(i, "Name " & i, i * 10, DateTime.Now.AddDays(i)) Next Return dataTable End Function Private Sub RadButton1_Click(sender As Object, e As EventArgs) Handles RadButton1.Click Dim pdfExporter = New GridViewPdfExport(Me.RadGridView1) AddHandler pdfExporter.CellFormatting, AddressOf pdfExporter_CellFormatting Dim renderer = New PdfExportRenderer() Dim fileName As String = "..\..\exported-grid.pdf" pdfExporter.RunExport(fileName, renderer) End Sub Private Sub pdfExporter_CellFormatting(sender As Object, e As PdfExportCellFormattingEventArgs) If e.RowIndex > -1 Then e.CellElement.Text = TryCast(RadDataConverter.Instance.Format(e.Row.Cells(e.ColumnIndex).Value, GetType(String), e.Column), String) End If End Sub End Class
To reproduce: run the attached sample project. You will notice the result illustrated in the provided screenshot. Although the grid is RTL, the print preview dialog show it in LTR. Workaround: public class CustomGridPrintStyle : GridPrintStyle { protected override BaseGridPrintRenderer InitializePrintRenderer(RadGridView grid) { if (this.PrintRenderer != null) { this.PrintRenderer.PrintCellPaint -= renderer_PrintCellPaint; this.PrintRenderer.PrintCellFormatting -= renderer_PrintCellFormatting; this.PrintRenderer.ChildViewPrinting -= renderer_ChildViewPrinting; } BaseGridPrintRenderer renderer = null; if (grid.ViewDefinition.GetType() == typeof(ColumnGroupsViewDefinition)) { if (!(renderer is ColumnGroupsViewDefinitionPrintRenderer)) { renderer = new CustomColumnGroupsViewDefinitionPrintRenderer(grid); } } else if (grid.ViewDefinition.GetType() == typeof(HtmlViewDefinition)) { if (!(renderer is HtmlViewDefinitionPrintRenderer)) { renderer = new HtmlViewDefinitionPrintRenderer(grid); } } else { if (!(renderer is TableViewDefinitionPrintRenderer)) { renderer = new TableViewDefinitionPrintRenderer(grid); } } renderer.ChildViewPrinting += renderer_ChildViewPrinting; renderer.PrintCellFormatting += renderer_PrintCellFormatting; renderer.PrintCellPaint += renderer_PrintCellPaint; return renderer; } private void renderer_PrintCellPaint(object sender, PrintCellPaintEventArgs e) { this.OnPrintCellPaint(sender, e); } private void renderer_PrintCellFormatting(object sender, PrintCellFormattingEventArgs e) { this.OnPrintCellFormatting(sender, e); } private void renderer_ChildViewPrinting(object sender, ChildViewPrintingEventArgs e) { this.OnChildViewPrinting(sender, e); } } public class CustomColumnGroupsViewDefinitionPrintRenderer : ColumnGroupsViewDefinitionPrintRenderer { public CustomColumnGroupsViewDefinitionPrintRenderer(RadGridView grid) : base(grid) { } protected override void PrintRow(GridViewRowInfo row, ColumnGroupRowLayout rowLayout, GridPrintSettings settings, int currentX, int currentY, Graphics graphics) { float scrollableColumnsOffset = 0f; float rightPinnedColumnsOffset = 0f; foreach (GridViewColumn col in rowLayout.RenderColumns) { if (col is GridViewRowHeaderColumn || col is GridViewIndentColumn) { continue; } float height = rowLayout.GetRowHeight(row); RectangleF cellBounds = rowLayout.GetCorrectedColumnBounds(row, col, this.GridView.RightToLeft == RightToLeft.Yes, new RectangleF(0f, 0f, rowLayout.DesiredSize.Width, height)); if (cellBounds == RectangleF.Empty) { continue; } if (col.PinPosition == PinnedColumnPosition.Left) { if (scrollableColumnsOffset < cellBounds.Right + rowLayout.Owner.CellSpacing) { scrollableColumnsOffset = cellBounds.Right + rowLayout.Owner.CellSpacing; rightPinnedColumnsOffset = scrollableColumnsOffset; } } else if (col.PinPosition == PinnedColumnPosition.None) { if (rightPinnedColumnsOffset < scrollableColumnsOffset + cellBounds.Right + rowLayout.Owner.CellSpacing) { rightPinnedColumnsOffset = scrollableColumnsOffset + cellBounds.Right + rowLayout.Owner.CellSpacing; } cellBounds.X += scrollableColumnsOffset; } else { cellBounds.X += rightPinnedColumnsOffset; } cellBounds.Offset(currentX, currentY); GridViewCellInfo cell; CellPrintElement printCell; if (row is GridViewTableHeaderRowInfo) { cell = this.GridView.MasterView.TableHeaderRow.Cells[col.Name]; printCell = this.CreateHeaderCellPrintElement(col); if (printCell.Font != settings.HeaderCellFont) { if (settings.HeaderCellFont != null) { printCell.Font = settings.HeaderCellFont; } else { settings.HeaderCellFont = printCell.Font; } } } else if (row is GridViewSummaryRowInfo) { GridViewSummaryRowInfo rowInfo = row as GridViewSummaryRowInfo; cell = rowInfo.Cells[col.Name]; if (cell == null) { continue; } printCell = this.CreateSummaryCellPrintElement(cell); if (printCell.Font != settings.SummaryCellFont) { if (settings.SummaryCellFont != null) { printCell.Font = settings.SummaryCellFont; } else { settings.SummaryCellFont = printCell.Font; } } } else { cell = row.Cells[col.Name]; if (cell == null) { continue; } if (col is GridViewImageColumn) { printCell = this.CreateImageCellPrintElement(cell); } else { printCell = this.CreateDataCellPrintElement(cell); if (printCell.Font != settings.CellFont) { if (settings.CellFont != null) { printCell.Font = settings.CellFont; } else { settings.CellFont = printCell.Font; } } } } printCell.TextPadding = this.GridView.PrintStyle.CellPadding; printCell.RightToLeft = this.GridView.RightToLeft == RightToLeft.Yes; Rectangle rect = new Rectangle((int)cellBounds.X, (int)cellBounds.Y, (int)cellBounds.Width, (int)cellBounds.Height); PrintCellFormattingEventArgs formattEventArgs = new PrintCellFormattingEventArgs(row, col, printCell); this.OnPrintCellFormatting(formattEventArgs); formattEventArgs.PrintCell.Paint(graphics, rect); PrintCellPaintEventArgs paintEventArgs = new PrintCellPaintEventArgs(graphics, row, col, rect); this.OnPrintCellPaint(paintEventArgs); } } } private void radButton1_Click(object sender, EventArgs e) { CustomGridPrintStyle style = new CustomGridPrintStyle(); this.radGridView1.PrintStyle = style; RadPrintDocument printDoc = new RadPrintDocument(); printDoc.Landscape = true; printDoc.RightHeader = "Right Header"; printDoc.HeaderHeight = 100; printDoc.AssociatedObject = this.radGridView1; RadPrintPreviewDialog dialog = new RadPrintPreviewDialog(printDoc); dialog.Size = new System.Drawing.Size(Screen.PrimaryScreen.Bounds.Width - 200, Screen.PrimaryScreen.Bounds.Height - 200); dialog.SetZoom(0.80); dialog.ShowDialog(); }
There should be a way for users to determine if a row passes a certain filter criteria without that affecting any data operations.
Workaround: create a custom RadListFilterPopup private void radGridView1_FilterPopupRequired(object sender, FilterPopupRequiredEventArgs e) { e.FilterPopup = new MyRadListFilterPopup(e.Column); } public class MyRadListFilterPopup : RadListFilterPopup { public MyRadListFilterPopup(GridViewDataColumn dataColumn) : base(dataColumn, false) { } protected override RadListFilterDistinctValuesTable GetDistinctValuesTable() { if (this.DataColumn.OwnerTemplate.HierarchyLevel == 0) { return base.GetDistinctValuesTable(); } GridViewColumnValuesCollection distinctValues = this.GetDistinctValuesWithFilter(this.DataColumn); RadListFilterDistinctValuesTable valuesTable = new RadListFilterDistinctValuesTable(); valuesTable.FormatString = this.DataColumn.FormatString; valuesTable.DataConversionInfoProvider = this.DataColumn; GridViewComboBoxColumn comboBoxColumn = this.DataColumn as GridViewComboBoxColumn; if (comboBoxColumn != null && !String.IsNullOrEmpty(comboBoxColumn.ValueMember)) { foreach (object value in distinctValues) { if (value != null && value != System.DBNull.Value) { object rowValue = value; object lookupValue = ((GridViewComboBoxColumn)this.DataColumn).GetLookupValue(value); if (comboBoxColumn.FilteringMode == GridViewFilteringMode.DisplayMember) { rowValue = lookupValue; } if (lookupValue != null) { valuesTable.Add(lookupValue.ToString(), rowValue); } } } } else { foreach (object value in distinctValues) { valuesTable.Add(value); } } return valuesTable; } private GridViewColumnValuesCollection GetDistinctValuesWithFilter(GridViewDataColumn column) { GridViewColumnValuesCollection distinctValues = new GridViewColumnValuesCollection(); int count = column.OwnerTemplate.ExcelFilteredColumns.Count; if ((count > 0 && column == column.OwnerTemplate.ExcelFilteredColumns[count - 1]) || column.OwnerTemplate.HierarchyLevel > 0) { if (count == 1 || column.OwnerTemplate.HierarchyLevel > 0) { int index = column.Index; if (index >= 0) { IList<GridViewRowInfo> templateRows = column.OwnerTemplate.Rows; if (templateRows.Count == 0 && column.OwnerTemplate.Parent != null && column.OwnerTemplate.HierarchyLevel > 0) { templateRows = new List<GridViewRowInfo>(); GridViewInfo templateViewInfo = column.OwnerTemplate.MasterViewInfo; for (int i = 0; i < column.OwnerTemplate.Parent.Rows.Count; i++) { GridViewRowInfo parentRow = column.OwnerTemplate.Parent.Rows[i]; ((List<GridViewRowInfo>)templateRows).AddRange(column.OwnerTemplate.HierarchyDataProvider.GetChildRows(parentRow, templateViewInfo)); } } foreach (GridViewRowInfo row in templateRows) { object cellValue = row.Cells[index].Value; if (!distinctValues.Contains(cellValue)) { distinctValues.Add(cellValue); } } if (distinctValues.Count > 0) { return distinctValues; } } } } return distinctValues; } }
The event should be used to cancel copying for a single cell or override the value to be copied to the Clipboard.
Until the new functionality becomes available you can use the workaround solution in the attached project.