Currently, DisplayFormatType.GeneralDate, DisplayFormatType.ShortDate, DisplayFormatType.MediumDate all return culture's DateTimeFormat.ShortDatePattern. Workaround: GridViewDateTimeColumn columnDateTime = this.radGridView1.Columns["Date"] as GridViewDateTimeColumn; columnDateTime.ExcelExportType = DisplayFormatType.Custom; columnDateTime.ExcelExportFormatString = "dd/MM/yyyy hh:mm:ss";
How to reproduce check the attached project: Workaround: Create a custom spread export renderer public class MySpreadExportRenderer : SpreadExportRenderer { public override void AddWorksheet(string sheetName) { string name = ""; Workbook wb = (Workbook)typeof(SpreadExportRenderer).GetField("workbook", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(this); if (sheetName == null || sheetName == string.Empty) { name = "Sheet_" + (wb.Worksheets.Count + 1); } else { name = sheetName; } if (wb.Worksheets.Where(w => w.Name == name).ToList().Count == 0) { base.AddWorksheet(sheetName); } else { typeof(SpreadExportRenderer).GetField("worksheet", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(this, wb.Worksheets.Add()); } } }
When I add summary rows to my radgridview. something strange is happening. I demonstrate it to you in two pictures. please take a look at attachments
Hi Mostafa, The end users can copy a single cell even when the SelectionMode is set to FullRowSelect via the ContextMenu when opening it on any of the data cells. If the context menu is opened on the row header they will select the whole row. Please check the attached video: radgridview-context-menu-behavior.gif. If you would like to copy a single cell using the Ctrl-C command and have the grid setup in FullRowSelect mode please check the attached project featuring a solution. I am also attaching a video showing the result using the custom implementation in the project: radgridview-full-row-ctrl-c.gif
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();
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 = ""; } } } }
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); }
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.
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; } }
Workaround: Use the Copying event.
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.
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: 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: private void RadGridView1_KeyPress(object sender, KeyPressEventArgs e) { int startIndex = radGridView1.CurrentRow.Index +1; for (int i = startIndex; i < radGridView1.Rows.Count; i++) { var value = radGridView1.Rows[i].Cells["Name"].Value.ToString().ToLower(); if (value.StartsWith(e.KeyChar.ToString())) { radGridView1.TableElement.ScrollToRow(radGridView1.Rows[i]); radGridView1.ClearSelection(); radGridView1.Rows[i].IsSelected = true; radGridView1.Rows[i].IsCurrent = true; radGridView1.Columns[1].IsCurrent = true; break; } } } - Press some key so the grid is scrolled down, then press the down key. - The first row is selected instead of the next one. Workaround: remove this line: radGridView1.Rows[i].IsSelected = true;
To reproduce: 1. Run the attached sample project. 2. Right-click the grid. 3. Quickly navigate to another application (e.g. Windows Explorer) before the context menu is shown & wait at windows explorer to display the menu 4. The context will be stuck.