To reproduce: - Bind the grid to a data source and set its RightToLeftProperty to true. Note: use Visual Studio 2008 under Windows XP with .NET 2.0 Workaround: Private Sub RadGridView1_ViewCellFormatting(ByVal sender As System.Object, ByVal e As Telerik.WinControls.UI.CellFormattingEventArgs) If RadGridView1.RightToLeft = Windows.Forms.RightToLeft.Yes Then e.CellElement.TextAlignment = ContentAlignment.MiddleLeft End If End Sub
To reproduce: - Add grid with a DateTime column with default value "5/1/2014"; - Start the app and press the following keys one after another: 5/1/ - You will notice that the "1" is not replaced. Please note that the similar behavior occur when the year is entered (it does not match the default one). Workaround handle the key press for such cases manually: void radGridView1_CellEditorInitialized(object sender, GridViewCellEventArgs e) { RadDateTimeEditor ed = e.ActiveEditor as RadDateTimeEditor; RadDateTimeEditorElement el = ed.EditorElement as RadDateTimeEditorElement; el.KeyPress += el_KeyPress; } private void el_KeyPress(object sender, KeyPressEventArgs e) { RadDateTimeEditorElement el = (RadDateTimeEditorElement)sender; int day = el.Value.Value.Day; int key = -1; int.TryParse(e.KeyChar.ToString(), key); RadMaskedEditBoxElement element = el.TextBoxElement.TextBoxItem.Parent as RadMaskedEditBoxElement; MaskDateTimeProvider provider = element.Provider as MaskDateTimeProvider; if (provider.SelectedItemIndex == 2) { if (key > 0 & key <= 9) { if (el.TextBoxElement.TextBoxItem.SelectionLength != 0) { if (!booKeying) { dynamic NewValue = new DateTime(el.Value.Value.Year, el.Value.Value.Month, key); el.Value = NewValue; e.Handled = true; booKeying = true; } } } } }
To reproduce: protected override void OnLoad(EventArgs e) { this.radGridView1.AllowAddNewRow = false; this.radGridView1.TableElement.RowHeight = 40; this.radGridView1.MasterTemplate.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill; GridViewTextBoxColumn id = new GridViewTextBoxColumn("ID"); id.IsVisible = false; GridViewTextBoxColumn parentID = new GridViewTextBoxColumn("ParentID"); parentID.IsVisible = false; GridViewTextBoxColumn name = new GridViewTextBoxColumn("Name"); GridViewDateTimeColumn date = new GridViewDateTimeColumn("Date"); GridViewTextBoxColumn type = new GridViewTextBoxColumn("Type"); GridViewTextBoxColumn size = new GridViewTextBoxColumn("Size"); size.FormatString = "{0} MB"; radGridView1.Columns.AddRange(new GridViewDataColumn[] { id, parentID, name, date, type, size }); this.radGridView1.Relations.AddSelfReference(this.radGridView1.MasterTemplate, "ID", "ParentID"); radGridView1.CellValueChanged += radGridView1_CellValueChanged; fillData(); } void radGridView1_CellValueChanged(object sender, GridViewCellEventArgs e) { fillData(); } private void fillData() { radGridView1.Rows.Clear(); radGridView1.Rows.Add(1, null, "Program Files", DateTime.Now.AddDays(-100), "Folder", 5120); radGridView1.Rows.Add(2, 1, "Visual Studio 2010", DateTime.Now.AddDays(-100), "Folder", 3220); radGridView1.Rows.Add(3, 2, "bin", DateTime.Now.AddDays(-100), "Folder", 3220); radGridView1.Rows.Add(4, 2, "READEME.txt", DateTime.Now.AddDays(-100), "Text Document", 3); radGridView1.Rows.Add(100, null, "Test.txt", DateTime.Now.AddDays(-10), "Text File", 0); radGridView1.Rows.Add(5, 1, "Telerik RadControls", DateTime.Now.AddDays(-10), "Folder", 3120); radGridView1.Rows.Add(6, 5, "Telerik UI for Winforms", DateTime.Now.AddDays(-10), "Folder", 101); radGridView1.Rows.Add(7, 5, "Telerik UI for Silverlight", DateTime.Now.AddDays(-10), "Folder", 123); radGridView1.Rows.Add(8, 5, "Telerik UI for WPF", DateTime.Now.AddDays(-10), "Folder", 221); radGridView1.Rows.Add(9, 5, "Telerik UI for ASP.NET AJAX", DateTime.Now.AddDays(-10), "Folder", 121); radGridView1.Rows.Add(10, 1, "Microsoft Office 2010", DateTime.Now.AddDays(-120), "Folder", 1230); radGridView1.Rows.Add(11, 10, "Microsoft Word 2010", DateTime.Now.AddDays(-120), "Folder", 1230); radGridView1.Rows.Add(12, 10, "Microsoft Excel 2010", DateTime.Now.AddDays(-120), "Folder", 1230); radGridView1.Rows.Add(13, 10, "Microsoft Powerpoint 2010", DateTime.Now.AddDays(-120), "Folder", 1230); radGridView1.Rows.Add(14, 1, "Debug Diagnostic Tools v1.0", DateTime.Now.AddDays(-400), "Folder", 2120); radGridView1.Rows.Add(15, 1, "Designer's 3D Tools", DateTime.Now.AddDays(-500), "Folder", 1120); radGridView1.Rows.Add(16, 1, "Communication", DateTime.Now.AddDays(-700), "Folder", 120); } Then start the application edit a value and click another cell. Workaround: - Enclose the rows addition within Begin/End update block.
To reproduce: 1. Add GridView which inherits the RadGridView 2. Populate the grid with some data 3. Add conditional formatting and set RowBackColor and CellBackColor 4. Subscribe to RowFormatting event and change the font of selected row: void radGridView2_RowFormatting(object sender, RowFormattingEventArgs e) { if (e.RowElement.IsSelected) { e.RowElement.Font = new Font(this.Font.FontFamily, this.Font.Size + 2, FontStyle.Bold); } else { e.RowElement.ResetValue(LightVisualElement.FontProperty, ValueResetFlags.Local); //e.RowElement.Font = this.Font; } } 5. Select row with conditional formatting. The font of selected row is bold which is correct. Select another row and you will see that the previous row is still bold. Workaround: Subscribe to CellFormatting event instead RowFormatting void radGridView2_CellFormatting(object sender, CellFormattingEventArgs e) { if (e.Row.IsSelected) { e.CellElement.Font = new Font(this.Font.FontFamily, this.Font.Size + 2, FontStyle.Bold); } else { e.CellElement.ResetValue(LightVisualElement.FontProperty, ValueResetFlags.Local); } }
BindingList<Item> items = new BindingList<Item>(); public Form1() { InitializeComponent(); for (int i = 0; i < 20; i++) { items.Add(new Item(i % 4, "Item" + i, "Type" + i % 2)); } this.radGridView1.DataSource = items; this.radGridView1.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill; } public class Item { public int Id { get; set; } public string Name { get; set; } public string Type { get; set; } public Item(int id, string name, string type) { this.Id = id; this.Name = name; this.Type = type; } } private void radButton1_Click(object sender, EventArgs e) { items.Insert(0, new Item(2, "Test", "Type0")); } WORKAROUND I: GridViewSynchronizationService.SuspendEvent(this.radGridView1.MasterTemplate, KnownEvents.CurrentChanged); Item item = new Item(2, "Test", "Type0"); items.Insert(0, item); GridViewSynchronizationService.ResumeEvent(this.radGridView1.MasterTemplate, KnownEvents.CurrentChanged); foreach (GridViewRowInfo row in this.radGridView1.Rows) { if (row.DataBoundItem == item) { this.radGridView1.CurrentRow = row; break; } } WORKAROUND II: this.radGridView1.Rows.CollectionChanged += Rows_CollectionChanged; this.radGridView1.GroupExpanding+=radGridView1_GroupExpanding; List<GridViewRowInfo> expandedGroups = new List<GridViewRowInfo>(); private void radGridView1_GroupExpanding(object sender, GroupExpandingEventArgs e) { if (!e.IsExpanded && shouldCollapse) { expandedGroups.Add(e.DataGroup.GroupRow); } } bool shouldCollapse = false; private void radButton1_Click(object sender, EventArgs e) { shouldCollapse = true; items.Insert(0, new Item(2, "Test", "Type0")); } private void Rows_CollectionChanged(object sender, Telerik.WinControls.Data.NotifyCollectionChangedEventArgs e) { if (e.Action == Telerik.WinControls.Data.NotifyCollectionChangedAction.Add) { this.radGridView1.CurrentRow = e.NewItems[0] as GridViewRowInfo; this.radGridView1.CurrentRow.IsSelected = true; GridViewRowInfo parent = this.radGridView1.CurrentRow.Parent as GridViewRowInfo; if (parent != null) { parent.IsExpanded = true; } if (shouldCollapse) { shouldCollapse = false; foreach (GridViewRowInfo r in expandedGroups) { if (!ContainsParentRow(parent, r)) { r.IsExpanded = false; } } expandedGroups.Clear(); } } } private bool ContainsParentRow(GridViewRowInfo parent, GridViewRowInfo r) { GridViewGroupRowInfo group = r as GridViewGroupRowInfo; if (group != null) { foreach (GridViewRowInfo childRow in group.ChildRows) { return ContainsParentRow(parent, childRow); } } return parent == r.Parent; }
To reproduce: 1. Add a grid to a form. 2. Set its SplitMode to vertical or horizontal. 3. Set its SynchronizeCurrentRowInSplitMode to false. You will notice that both grids are synchronized. Workaround: Add two RadgridViews in a RadSplitContainer with two split panels and use two separate data sources. For example: List<string> ds = new List<string>(); grid1.DataSource = ds; grid2.DataSource = ds.ToArray();
If RadGridView is bound to custom objects that implement IComparable<T>, Excel-like filtering does not work. Currently, the issue can be avoided through implementing IComparable instead.
To reproduce: use the following code snippet: Sub New() InitializeComponent() Me.RadGridView1.EnableFiltering = True Me.RadGridView1.ShowHeaderCellButtons = True Dim dt As New DataTable dt.Columns.Add("Id", GetType(Integer)) dt.Columns.Add("Name", GetType(String)) dt.Columns.Add("Type", GetType(String)) dt.Columns.Add("Active", GetType(Boolean)) Dim typeList As New List(Of String) typeList.Add("REFERRAL") typeList.Add("EMPLOYEE") typeList.Add("Type3") typeList.Add("Type4") Dim rand As New Random For index = 1 To 10 dt.Rows.Add(index, "Name" & index, typeList(rand.Next(0, typeList.Count)),If(index mod 2=0, True,false)) Next Me.RadGridView1.AutoGenerateColumns = False Dim decimalColumn As New GridViewDecimalColumn("ID") decimalColumn.FieldName = "Id" RadGridView1.MasterTemplate.Columns.Add(decimalColumn) Dim textBoxColumn As New GridViewTextBoxColumn("Name") textBoxColumn.FieldName = "Name" RadGridView1.MasterTemplate.Columns.Add(textBoxColumn) Dim supplierColumn As GridViewComboBoxColumn = New GridViewComboBoxColumn("Type") supplierColumn.FieldName = "Type" supplierColumn.DataSource = typeList Me.RadGridView1.Columns.Add(supplierColumn) Dim checkBoxColumn As New GridViewCheckBoxColumn("Active") checkBoxColumn.FieldName = "Active" RadGridView1.MasterTemplate.Columns.Add(checkBoxColumn) Me.RadGridView1.DataSource = dt Me.RadGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill End Sub Private Sub RadButton1_Click(sender As Object, e As EventArgs) Handles RadButton1.Click Dim activeFilter As New FilterDescriptor() activeFilter.PropertyName = "Active" activeFilter.Operator = FilterOperator.IsEqualTo activeFilter.Value = True Dim typeFilter As New CompositeFilterDescriptor() typeFilter.FilterDescriptors.Add(New FilterDescriptor("Type", FilterOperator.IsEqualTo, "EMPLOYEE")) typeFilter.FilterDescriptors.Add(New FilterDescriptor("Type", FilterOperator.IsEqualTo, "REFERRAL")) typeFilter.LogicalOperator = FilterLogicalOperator.Or Dim overallFilterDescriptor As New CompositeFilterDescriptor() 'overallFilterDescriptor.PropertyName = "Type" 'overallFilterDescriptor.IsFilterEditor = True overallFilterDescriptor.FilterDescriptors.Add(typeFilter) overallFilterDescriptor.FilterDescriptors.Add(activeFilter) overallFilterDescriptor.LogicalOperator = FilterLogicalOperator.And Me.RadGridView1.FilterDescriptors.Add(overallFilterDescriptor) End Sub Run the project and click the button. You will see that the filter button is not orange indicating that there is applied filter. Additionally, the "Clear filter" option is disabled and the user is not allowed to see the entire data any more. Workaround: set the overall CompositeFilterDescriptor.PropertyName to a specific column and the IsFilterEditor property to true. Thus, you will be allowed to clear the filter from this column.
Deleting a Template in the Property Builder does work.
1. Create a new project with RadGridView. 2. Bind it and set grouping. 3. Add a summary row and set ShowParentGroupSummaries property to true. 4. Handle the ViewCellFormatting event and set all summary rows to be IsVisible = false when the processed cell is GridSummaryCellElement: void radGridView1_ViewCellFormatting(object sender, CellFormattingEventArgs e) { if (e.CellElement is GridSummaryCellElement) { e.Row.IsVisible = false; } } CORRECT WAY TO HANDLE THIS CASE: Hide the summary rows in the groups you want after grouping/data binding. To hide the first bottom summary row of the first group in a RadGridView use the following code: this.radGridView1.Groups[0].GroupRow.BottomSummaryRows[0].IsVisible = false;
Synchronization between the filter descriptors collection and the excel like filtering.
DECLINED: This happens because you are setting a non-image value to a GridViewImageColumn. The GridViewImageColumn is designed to work with image data directly and if any non-image data is used with this column, this will result in a large number of internal exceptions which are thrown while the column tries to read the image. The throw operation is an expensive one and this causes the slowdown. Also, note that the slowdown is much heavier when running the application with the debugger attached, because when this is the case, each internally thrown exception is written to the console, and writing to the console is an even more expensive operation. If the image is to be applied on the CellFormatting event and the value of the cells in a column are not going to be images, then GridViewTextBoxColumn should be used instead. To reproduce: add a RadGridView and an ImageList with two images. Use the following code snippet: public Form1() { InitializeComponent(); DataTable dt = new DataTable(); for (int i = 0; i < 10; i++) { dt.Columns.Add("Pic" + i); } for (int i = 0; i < 100; i++) { DataRow newRow = dt.NewRow(); foreach (DataColumn col in dt.Columns) { newRow[col.ColumnName] = i; } dt.Rows.Add(newRow); } radGridView1.AutoGenerateColumns = false; for (int i = 0; i < 10; i++) { GridViewImageColumn imgCol = new GridViewImageColumn("col" + i); imgCol.Width = 100; imgCol.FieldName = "Pic" + i; this.radGridView1.Columns.Add(imgCol); } this.radGridView1.DataSource = dt; this.radGridView1.CellFormatting += radGridView1_CellFormatting; } private void radGridView1_CellFormatting(object sender, CellFormattingEventArgs e) { if (e.Row is GridViewDataRowInfo) { e.CellElement.Image = this.imageList1.Images[e.RowIndex % 2]; } }
Steps to reproduce: 1. Add a GridViewDateTimeColumn to a grid. 2. Add rows where one or more rows should contain null as the columns value. 3. Sort the grid by the date time column. WORKAROUND: Create a custom RadGridDateTimeConverter and assign it as the column's date type converter: public class CustomRadGridDateTimeConverter : RadGridDateTimeConverter { public CustomRadGridDateTimeConverter(GridViewDateTimeColumn column) : base(column) { } public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType) { if (destinationType == typeof(DateTime) && value == null) { return DateTime.MinValue; } return base.ConvertTo(context, culture, value, destinationType); } } this.radGridView1.Columns["DateTime"].DataTypeConverter = new CustomRadGridDateTimeConverter(this.radGridView1.Columns["DateTime"] as GridViewDateTimeColumn);
There should be a Enum (Left, Right, None) property of the Expander Column indicating whether the position of the expander column should be left right or none. This would be especially important during pinning activities meaning no matter how many columns are being pinned and repositioned in the pinned area of the grid, it would always remain on the left, right or none.
The horizontal scrollbar of the control does not behave correctly when there are several pinned columns and their width is larger than the visible area of RadGridView.
The RadGridView should not leave its edit mode state, when scrolling is performed.
To reproduce: - Add two GridViewMultiComboBoxColumns with different number of columns to a grid. - set AutoSizeDropDownToBestFit to true in the CellEditorInitialized event. - Start the project and open the drop down for the first column and then for the second. - You will notice that the second time the drop down size is not calculated properly. Workaround: void radGridView1_CellEditorInitialized(object sender, GridViewCellEventArgs e) { RadMultiColumnComboBoxElement el = e.ActiveEditor as RadMultiColumnComboBoxElement; if (el != null) { FieldInfo propertyInfo = el.GetType().GetField("savedColumnsWidth", BindingFlags.NonPublic | BindingFlags.Instance); propertyInfo.SetValue(el, -1); el.AutoSizeDropDownToBestFit = true; } }
RadGridView should be able to create new rows using objects with properties matching the FieldNames of the control's columns.
1. Create a new project with RadGridView. 2. Bind it. 3. Add some filter descriptors. 4. Handle the CustomFiltering event and add custom filter for some column. 5. Run the project and you will see that all other filters are not applied.