How to reproduce: public partial class Form1 : Form { private DataTable dt = new DataTable(); public Form1() { InitializeComponent(); this.FillData(); this.radGridView1.DataSource = this.dt; this.radGridView1.EnableSorting = true; this.radGridView1.EnableFiltering = true; this.radGridView1.MasterTemplate.DataView.BypassSort = true; this.radGridView1.SortChanged += radGridView1_SortChanged; this.radGridView1.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill; } public void FillData() { dt.Columns.Add("Id", typeof(int)); dt.Columns.Add("Name", typeof(string)); for (int i = 0; i < 30; i++) { dt.Rows.Add(i, "Item" + i); } } private void radGridView1_SortChanged(object sender, Telerik.WinControls.UI.GridViewCollectionChangedEventArgs e) { if (e.Action == NotifyCollectionChangedAction.Add || e.Action == NotifyCollectionChangedAction.ItemChanged) { SortDescriptor s = e.NewItems[0] as SortDescriptor; string sortOperator = ""; if (s.Direction == ListSortDirection.Ascending) { sortOperator = "ASC"; } else { sortOperator = "DESC"; } dt.DefaultView.Sort = s.PropertyName + " " + sortOperator; } if (e.Action == NotifyCollectionChangedAction.Remove) { dt.DefaultView.Sort = ""; } } } Workaround: public partial class Form1 : Form { private DataTable dt = new DataTable(); public Form1() { InitializeComponent(); this.FillData(); this.radGridView1.DataSource = this.dt; this.radGridView1.EnableSorting = true; this.radGridView1.EnableFiltering = true; this.radGridView1.MasterTemplate.DataView.BypassSort = true; this.radGridView1.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill; this.radGridView1.CellBeginEdit += RadGridView1_CellBeginEdit; this.radGridView1.CellEndEdit += RadGridView1_CellEndEdit; } private void RadGridView1_CellEndEdit(object sender, GridViewCellEventArgs e) { if (e.Row is GridViewFilteringRowInfo) { this.radGridView1.MasterTemplate.DataView.BypassSort = true; } } private void RadGridView1_CellBeginEdit(object sender, Telerik.WinControls.UI.GridViewCellCancelEventArgs e) { if (e.Row is GridViewFilteringRowInfo) { this.radGridView1.MasterTemplate.DataView.BypassSort = false; } } public void FillData() { dt.Columns.Add("Id", typeof(int)); dt.Columns.Add("Name", typeof(string)); for (int i = 0; i < 30; i++) { dt.Rows.Add(i, "Item" + i); } } }
How to reproduce public partial class Form1 : RadForm { public Form1() { InitializeComponent(); GridViewTextBoxColumn textBoxColumn = new GridViewTextBoxColumn(); textBoxColumn.Name = "Column"; textBoxColumn.HeaderText = "Column"; this.radGridView1.MasterTemplate.Columns.Add(textBoxColumn); GridViewTextBoxColumn textBoxColumn2 = new GridViewTextBoxColumn(); textBoxColumn2.Name = "TextBoxColumn2"; textBoxColumn2.HeaderText = "ReadOnlyColumn"; this.radGridView1.MasterTemplate.Columns.Add(textBoxColumn2); for (int i = 0; i < 10; i++) { object v = i * 2; if (i % 3 == 0) { v = null; } this.radGridView1.Rows.Add(new object[] { i, v }); } this.radGridView1.MultiSelect = true; foreach (var row in this.radGridView1.Rows) { foreach (var cell in row.Cells) { GridViewCellInfo cellInfo = cell as GridViewCellInfo; if (cellInfo != null && cellInfo.RowInfo.Index % 3 == 0 && cellInfo.ColumnInfo.Index == 1) { cellInfo.ReadOnly = true; } } } } } Workaround: public class MyRadGridView : RadGridView { public override string ThemeClassName { get { return typeof(RadGridView).FullName; } } protected override RadGridViewElement CreateGridViewElement() { return new MyRadGridViewElement(); } } internal class MyRadGridViewElement : RadGridViewElement { protected override Type ThemeEffectiveType { get { return typeof(RadGridViewElement); } } protected override MasterGridViewTemplate CreateTemplate() { return new MyMasterGridViewTemplate(); } } internal class MyMasterGridViewTemplate : MasterGridViewTemplate { protected override void PasteDataToRow(List<string> rowData, GridViewRowInfo row) { { int colIndex = this.Owner.CurrentColumn.Index; int j = 0; while (j < rowData.Count && colIndex < this.CurrentView.ViewTemplate.ColumnCount) { GridViewColumn col = this.CurrentView.ViewTemplate.Columns[colIndex]; if (col.IsVisible && !col.ReadOnly && !row.Cells[colIndex].ReadOnly) { object value = rowData[j]; if (string.IsNullOrEmpty(rowData[j])) { value = null; } else if (this.CurrentView.ViewTemplate.Columns[colIndex].DataType == typeof(string)) { GridViewTextBoxColumn textColumn = col as GridViewTextBoxColumn; if (textColumn != null && textColumn.MaxLength > 0) { if (rowData[j].Length > textColumn.MaxLength) { value = rowData[j].Substring(0, textColumn.MaxLength); } } } else if (this.CurrentView.ViewTemplate.Columns[colIndex].DataType == typeof(DateTime)) { try { value = DateTime.Parse(rowData[j], this.CurrentView.ViewTemplate.Columns[colIndex].FormatInfo); } catch { } } else if (this.CurrentView.ViewTemplate.Columns[colIndex].DataType == typeof(Color)) { try { value = ColorTranslator.FromHtml(rowData[j]); } catch { } } if (this.ClipboardPasteMode == GridViewClipboardPasteMode.EnableWithNotifications) { CellValidatingEventArgs cellValidating = new CellValidatingEventArgs(row, col, value, row.Cells[colIndex].Value, null); this.EventDispatcher.RaiseEvent<CellValidatingEventArgs>(EventDispatcher.CellValidating, this, cellValidating); if (!cellValidating.Cancel) { row.Cells[colIndex].Value = value; CellValidatedEventArgs cellValidated = new CellValidatedEventArgs(row, col, value); this.EventDispatcher.RaiseEvent<CellValidatedEventArgs>(EventDispatcher.CellValidated, this, cellValidated); } } else { row.Cells[colIndex].Value = value; } j++; } colIndex++; } } } }
To reproduce: run the attached sample project: 1. Clear the value in one of the cells. 2. Select the empty cell and press Ctrl+C to copy the empty cell. You will encounter the error coming from the GetFormattedCellValue method. Workaround: handle the RadGridView.Copying event private void RadGridView1_Copying(object sender, GridViewClipboardEventArgs e) { if (this.radGridView1.SelectionMode == GridViewSelectionMode.FullRowSelect) { foreach (var row in this.radGridView1.SelectedRows) { foreach (var cell in row.Cells) { GridViewCellInfo cellInfo = cell as GridViewCellInfo; if (cellInfo != null && cellInfo.Value == null) { cellInfo.Value = ""; } } } } else { foreach (var cell in this.radGridView1.SelectedCells) { if (cell.Value == null) { cell.Value = ""; } } } }
To reproduce: - Create ColumnGroupsViewDefinition and export it with the following code: SpreadExportRenderer renderer = new SpreadExportRenderer(); GridViewSpreadExport spreadExporter = new GridViewSpreadExport(radGridView1); spreadExporter.FreezeHeaderRow = true; spreadExporter.ExportViewDefinition = true; spreadExporter.ExportVisualSettings = true; spreadExporter.ExportGroupedColumns = true; spreadExporter.ExportHierarchy = true; spreadExporter.SheetMaxRows = ExcelMaxRows._1048576; spreadExporter.ExportFormat = SpreadExportFormat.Xlsx; spreadExporter.FileExportMode = FileExportMode.CreateOrOverrideFile; spreadExporter.RunExport(dialog.FileName, renderer); Workaround: - Set FreezeHeaderRow to false. You can manually freeze the rows as well: private void Renderer_WorkbookCreated(object sender, WorkbookCreatedEventArgs e) { e.Workbook.ActiveWorksheet.ViewState.FreezePanes(2, 0); }
How to reproduce: public partial class Form1 : Form { public Form1() { InitializeComponent(); this.radGridView1.DataSource = this.GetData(); GridViewComboBoxColumn supplierColumn = new GridViewComboBoxColumn(); supplierColumn.Name = "SupplierColumn"; supplierColumn.HeaderText = "Supplier"; supplierColumn.DataSource = this.GetListItemData(); ; supplierColumn.ValueMember = "Id"; supplierColumn.DisplayMember = "Description"; supplierColumn.Width = 200; this.radGridView1.Columns.Add(supplierColumn); this.radGridView1.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill; this.radGridView1.CellEditorInitialized += RadGridView1_CellEditorInitialized; } private void RadGridView1_CellEditorInitialized(object sender, GridViewCellEventArgs e) { RadDropDownListEditor editor = e.ActiveEditor as RadDropDownListEditor; if (editor == null) { return; } RadDropDownListEditorElement element = (RadDropDownListEditorElement)editor.EditorElement; element.ValueChanging -= Element_ValueChanging; element.ValueChanging += Element_ValueChanging; } private void Element_ValueChanging(object sender, ValueChangingEventArgs e) { Console.WriteLine("ValueChanging"); Console.WriteLine("Old " + e.OldValue); Console.WriteLine("New " + e.NewValue); } private object GetData() { DataTable dt = new DataTable(); dt.Columns.Add("Id", typeof(int)); dt.Columns.Add("Name", typeof(string)); dt.Columns.Add("Date", typeof(DateTime)); for (int i = 0; i < 100; i++) { dt.Rows.Add(i, "Name " + i, DateTime.Now.AddDays(i)); } return dt; } public List<Item> GetListItemData() { List<Item> items = new List<Item>(); for (int i = 0; i < 10; i++) { items.Add(new Item(i, "Data" + i, DateTime.Now.AddDays(i).AddHours(i))); } return items; } } public class Item { public int Id { get; set; } public string Description { get; set; } public DateTime Date { get; set; } public Item(int id, string description, DateTime date) { this.Id = id; this.Description = description; this.Date = date; } } Workaround: handle the TextChanging event and store locally the old value private void RadGridView1_CellEditorInitialized(object sender, GridViewCellEventArgs e) { RadDropDownListEditor editor = e.ActiveEditor as RadDropDownListEditor; if (editor == null) { return; } RadDropDownListEditorElement element = (RadDropDownListEditorElement)editor.EditorElement; element.TextChanging-= Element_TextChanging; element.TextChanging += Element_TextChanging; element.ValueChanging -= Element_ValueChanging; element.ValueChanging += Element_ValueChanging; } object oldValue; private void Element_TextChanging(object sender, TextChangingEventArgs e) { oldValue = e.OldValue; } private void Element_ValueChanging(object sender, ValueChangingEventArgs e) { Console.WriteLine("ValueChanging"); Console.WriteLine("Old " + oldValue); Console.WriteLine("New " + e.NewValue); }
How to reproduce: public partial class Form1 : Form { public Form1() { InitializeComponent(); this.radGridView1.DataSource = this.GetData(); this.radGridView1.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill; this.radGridView1.EnableFiltering = true; this.radGridView1.ShowHeaderCellButtons = true; this.radGridView1.FilterPopupRequired += RadGridView1_FilterPopupRequired; GridViewDateTimeColumn date = this.radGridView1.Columns["Date"] as GridViewDateTimeColumn; date.DataType = typeof(DateTime); date.FilteringMode = GridViewTimeFilteringMode.Date; } private void RadGridView1_FilterPopupRequired(object sender, Telerik.WinControls.UI.FilterPopupRequiredEventArgs e) { if (e.Column.GetType().Name == "GridViewDateTimeColumn") { RadListFilterPopup popup = new RadListFilterPopup(e.Column, true); e.FilterPopup = popup; } } private object GetData() { DataTable dt = new DataTable(); dt.Columns.Add("Id", typeof(int)); dt.Columns.Add("Name", typeof(string)); dt.Columns.Add("Date", typeof(DateTime)); dt.Columns.Add("Bool", typeof(bool)); DateTime date = DateTime.Now; for (int i = 0; i < 1500; i++) { dt.Rows.Add(i, "Name " + i, date.AddDays(i), i % 2 == 0); } return dt; } Workaround: custom RadListFilterPopup public class MyRadListFilterPopup : RadListFilterPopup { public MyRadListFilterPopup(GridViewDataColumn dataColumn, bool groupedDateValues) : base(dataColumn, groupedDateValues) { } protected override void OnButtonOkClick(EventArgs e) { FilterOperator filterOperator = FilterOperator.IsEqualTo; IRadListFilterElement listFilterElement = typeof(RadListFilterPopup).GetField("listFilterElement", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic). GetValue(this) as IRadListFilterElement; switch (listFilterElement.SelectedMode) { case ListFilterSelectedMode.All: filterOperator = FilterOperator.None; break; case ListFilterSelectedMode.Null: filterOperator = FilterOperator.IsNull; break; case ListFilterSelectedMode.NotNull: filterOperator = FilterOperator.IsNotNull; break; } if (filterOperator != FilterOperator.IsEqualTo) { SetFilterOperator(filterOperator); this.ClosePopup(RadPopupCloseReason.CloseCalled); } else { CompositeFilterDescriptor compositeFilterDescriptor = new CompositeFilterDescriptor(); compositeFilterDescriptor.PropertyName = base.DataColumn.Name; compositeFilterDescriptor.LogicalOperator = FilterLogicalOperator.Or; foreach (DictionaryEntry entry in listFilterElement.SelectedValues) { foreach (object value in (ArrayList)entry.Value) { FilterDescriptor descriptor; if (base.DataColumn is GridViewDateTimeColumn || base.DataColumn.DataType == typeof(DateTime) || base.DataColumn.DataType == typeof(DateTime?)) { descriptor = new DateFilterDescriptor(base.DataColumn.Name, FilterOperator.IsEqualTo, (DateTime?)value, false); } else { descriptor = new FilterDescriptor(base.DataColumn.Name, FilterOperator.IsEqualTo, value); } compositeFilterDescriptor.FilterDescriptors.Add(descriptor); } } base.FilterDescriptor = compositeFilterDescriptor; OnFilterConfirmed(); } } }
To reproduce: Please refer to the attached gif file and follow the steps DataTable dt = new DataTable(); dt.Columns.Add("Id", typeof(int)); dt.Columns.Add("ParentId", typeof(int)); dt.Columns.Add("Date", typeof(DateTime)); Random rand = new Random(); for (int i = 0; i < 5; i++) { dt.Rows.Add(i, -1, DateTime.Now); } for (int j = 5; j < 10; j++) { dt.Rows.Add(j, rand.Next(0, 5), DateTime.Now.AddDays(j)); } this.radGridView1.Relations.AddSelfReference(this.radGridView1.MasterTemplate, "Id", "ParentId"); this.radGridView1.DataSource = dt; this.radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill; GridViewDateTimeColumn dateTimeColumn = this.radGridView1.Columns.Last() as GridViewDateTimeColumn; dateTimeColumn.FilteringMode = GridViewTimeFilteringMode.Date; this.radGridView1.EnableFiltering = true; Workaround: use the standard hierarchy: http://docs.telerik.com/devtools/winforms/gridview/hierarchical-grid/binding-to-hierarchical-data-programmatically OR the custom filtering: http://docs.telerik.com/devtools/winforms/gridview/filtering/custom-filtering
To reproduce: 1. Filter the first column in the grid 2. Click the header checkbox 3. Try to clear the filter. you iwll notice that the data is still filtered. Workaround: private void radGridView1_CreateCell(object sender, GridViewCreateCellEventArgs e) { if (e.CellType==typeof(GridCheckBoxHeaderCellElement)) { e.CellElement = new CustomHeaderCell(e.Column, e.Row); } } public class CustomHeaderCell : GridCheckBoxHeaderCellElement { public CustomHeaderCell(GridViewColumn column, GridRowElement row) : base(column, row) { } protected override void checkbox_ToggleStateChanged(object sender, StateChangedEventArgs args) { base.checkbox_ToggleStateChanged(sender, args); this.TableElement.EndUpdate(false); } }
How to reproduce: Check the attached video --> radgridview-filtering.gif Workaround: public partial class Form1 : Form { public Form1() { InitializeComponent(); this.radGridView1.DataSource = this.GetData(); this.radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill; this.radGridView1.EnableFiltering = true; this.radGridView1.FilterChanging += RadGridView1_FilterChanging; this.radGridView1.FilterChanged += RadGridView1_FilterChanged; } private void RadGridView1_FilterChanged(object sender, GridViewCollectionChangedEventArgs e) { if (clearFiler) { this.radGridView1.FilterDescriptors.Remove((FilterDescriptor)e.NewItems[0]); clearFiler = false; } } bool clearFiler = false; private void RadGridView1_FilterChanging(object sender, GridViewCollectionChangingEventArgs e) { if (e.PropertyName == "Operator" && e.Action == Telerik.WinControls.Data.NotifyCollectionChangedAction.ItemChanging) { FilterDescriptor fd = e.OldItems[0] as FilterDescriptor; if (fd != null && (fd.Operator == FilterOperator.IsNull || fd.Operator == FilterOperator.IsNotNull)) { clearFiler = true; } } } private object GetData() { DataTable dt = new DataTable(); dt.Columns.Add("Id", typeof(int)); dt.Columns.Add("Name", typeof(string)); dt.Columns.Add("Date", typeof(DateTime)); dt.Columns.Add("Bool", typeof(bool)); for (int i = 0; i < 100; i++) { dt.Rows.Add(i, "Name " + i, DateTime.Now.AddDays(i), i % 2 == 0); } return dt; } }
Use attached to reproduce. Workaround: class MyViewDefinition : TableViewDefinition { public override IRowView CreateViewUIElement(GridViewInfo viewInfo) { return new MyTableElement(); } } class MyTableElement : GridTableElement { public override void DpiScaleChanged(SizeF scaleFactor) { if (this.ViewTemplate != null) { base.DpiScaleChanged(scaleFactor); } } protected override Type ThemeEffectiveType { get { return typeof(GridTableElement); } } } //use the above definition like this: radGridView1.ViewDefinition = new MyViewDefinition();
Workaround: Use the Copying event.
How to reproduce: Create a grid with enabled filtering and open the excel-like filter popup of a DateTime column. Workaround: public partial class Form1 : Form { public Form1() { InitializeComponent(); this.radGridView1.DataSource = this.GetData(); this.radGridView1.EnableFiltering = true; this.radGridView1.ShowFilteringRow = true; this.radGridView1.ShowHeaderCellButtons = true; this.radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill; this.radGridView1.FilterPopupInitialized += RadGridView1_FilterPopupInitialized; } private void RadGridView1_FilterPopupInitialized(object sender, FilterPopupInitializedEventArgs e) { RadDateFilterPopup popup = e.FilterPopup as RadDateFilterPopup; if (popup != null && popup.Width < 300) { popup.Width += 100; popup.Height += 100; } } private object GetData() { DataTable dt = new DataTable(); dt.Columns.Add("Id", typeof(int)); dt.Columns.Add("Name", typeof(string)); dt.Columns.Add("Bool", typeof(bool)); dt.Columns.Add("Date", typeof(DateTime)); for (int i = 0; i < 100; i++) { dt.Rows.Add(i, "Name " + i, i % 2 == 0, DateTime.Now.AddDays(1)); } return dt; } }
To reproduce: please refer to the attached sample project. Click the button several times to add 3-4000 rows and toggle the checkbox. You will notice that every time you add new rows and hide the column it takes a long time. The more rows you have, the more time it requires. Workaround: radGridView1.MasterTemplate.BeginUpdate(); radGridView1.Columns[0].IsVisible = checkBox1.Checked; radGridView1.MasterTemplate.EndUpdate();
Steps to reproduce: 1. Set DPI scale to 150 of all screens 2. Run attached sample 3. The column`s width is not calculated correctly.
Attached project for reproducing. Workaround: var column = radGridView1.Columns[2] as GridViewDecimalColumn; var format = column.FormatString; column.FormatString = ""; column.ExcelExportType = DisplayFormatType.Currency; //export the grid column.FormatString = format;
Please refer to the attached sample project and follow the steps illustrated in the attached gif file.
To reproduce: - Add a grid to a PageView and add the pageView to a dock window at run time. - The grid should not be visible. - Set your DPI setting to 150% Workaround: class MyViewDefinition : TableViewDefinition { public override IRowView CreateViewUIElement(GridViewInfo viewInfo) { return new MyTableElement(); } } class MyTableElement : GridTableElement { public override void DpiScaleChanged(SizeF scaleFactor) { if (this.ViewTemplate != null) { base.DpiScaleChanged(scaleFactor); } } protected override Type ThemeEffectiveType { get { return typeof(GridTableElement); } } } //use the above definition like this: radGridView1.ViewDefinition = new MyViewDefinition();
To reproduce: public Form1() { InitializeComponent(); DataTable dt = new DataTable(); dt.Columns.Add("Id", typeof(int)); dt.Columns.Add("Name", typeof(string)); dt.Columns.Add("ParentId", typeof(int)); for (int i = 0; i < 3; i++) { dt.Rows.Add(i, "Parent" + i, -1); } Random rand = new Random(); for (int i = 3; i < 15; i++) { dt.Rows.Add(i,"Child"+i,rand.Next(0,3)); } this.radGridView1.Relations.AddSelfReference(this.radGridView1.MasterTemplate, "Id", "ParentId"); this.radGridView1.DataSource = dt; this.radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill; this.radGridView1.EnableGrouping = true; this.radGridView1.EnableCustomGrouping = true; this.radGridView1.CustomGrouping+=radGridView1_CustomGrouping; } private void radGridView1_CustomGrouping(object sender, GridViewCustomGroupingEventArgs e) { }
To reproduce: 1. Bind RadGridView to the Northwind.Customers table. 2. Activate the editor for some of the cells from the CustomerID column. 3. Enter "ALFKI" which already exists. The DataError event is supposed to be fired in this case. If you set the GridViewDataErrorEventArgs.ThrowException argument to true the exception is supposed to be thrown. However, nothing happens. Please refer to the attached sample project.