To reproduce: - Add several rows to a grid where the paging is enabled (make sure that last row has unique values) - Use the excel like filtering in the first page, notice that the last value is missing. Workaround: void radGridView1_FilterPopupInitialized(object sender, FilterPopupInitializedEventArgs e) { RadListFilterPopup popup = e.FilterPopup as RadListFilterPopup; if (popup != null) { foreach (GridViewRowInfo row in radGridView1.Rows) { var value = row.Cells[e.Column.Name].Value; if (!(popup.MenuTreeElement.DistinctListValues.Contains(value))) { popup.MenuTreeElement.DistinctListValues.Add(value.ToString(), value.ToString()) ; } } } }
To reproduce: public Form1() { InitializeComponent(); List<DiffItem> diffItemsMain = GetSampleDataDiffItems(12500); radGridView1.DataSource = diffItemsMain; radGridView1.Relations.AddSelfReference(radGridView1.MasterTemplate, "Index", "ParentIndex"); radGridView1.MasterTemplate.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill; } private List<DiffItem> GetSampleDataDiffItems(int rootInstances) { List<DiffItem> diffItems = new List<DiffItem>(); for (int j = 0; j < rootInstances; j++) { string[,] sampleData = GetSampleDataArray(); string parentIndex = ""; for (int i = 0; i <= sampleData.GetUpperBound(0); i++) { DiffItem diffItem = new DiffItem(Guid.NewGuid().ToString()); diffItem.ObjectStatus = sampleData[i, 0]; diffItem.ObjectType = sampleData[i, 1]; diffItem.ObjectLabel = sampleData[i, 2]; diffItem.ChangeType = sampleData[i, 3]; diffItem.ObjectAccepted = sampleData[i, 4]; diffItem.ParentIndex = parentIndex; diffItems.Add(diffItem); parentIndex = diffItem.Index; } } return diffItems; } private string[,] GetSampleDataArray() { string[,] sampleData = new string[,] { { "New", "Parent", "A572", "Added", "Undecided" }, { "New", "Child", "CM1", "Added", "Undecided" }, { "Modified", "GrandChild", "A573", "Modified", "Undecided" }, { "Modified", "GreatGrandChild", "CM2", "Modified", "Undecided" } }; return sampleData; } public class DiffItem { public DiffItem(string index) { Index = index; } public string ObjectStatus { get; set; } public string Index { get; set; } public bool ObjectSelected { get; set; } public string ObjectType { get; set; } public string ObjectLabel { get; set; } public string ChangeType { get; set; } public string ObjectAccepted { get; set; } public string ParentIndex { get; set; } } Try to edit one random cell. You will notice that after pressing the Enter key to commit the changes, the editor is closed after a few seconds. Resolution: The slowdown should be experienced only when editing columns which participate in the self-reference relation.
Use the following code snippet: public Form1() { InitializeComponent(); DataTable dt = new DataTable(); dt.Columns.Add("Id", typeof(int)); dt.Columns.Add("Item", typeof(string)); dt.Columns.Add("Price", typeof(decimal)); for (int i = 0; i < 10; i++) { dt.Rows.Add(i % 5, "Item" + i, i * 2.25m); } this.radGridView1.DataSource = dt; GridViewDecimalColumn customCalculatedCol = new GridViewDecimalColumn("Custom Calculated Column"); customCalculatedCol.Name = "Custom Calculated Column"; customCalculatedCol.Expression = "SumIf(Id)"; radGridView1.Columns.Add(customCalculatedCol); GridViewDecimalColumn customCalculatedCola = new GridViewDecimalColumn("Custom Col_A"); radGridView1.Columns.Add(customCalculatedCola); this.radGridView1.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill; Telerik.Data.Expressions.ExpressionContext.Context = new CustomExpressionContext(radGridView1); } public class CustomExpressionContext : Telerik.Data.Expressions.ExpressionContext { private RadGridView grid; public CustomExpressionContext(RadGridView grid) { this.grid = grid; } public double SumIf(int currentId) { double countIf = 0; decimal sumIf = 0; foreach (GridViewRowInfo r in this.grid.Rows) { if ((int)r.Cells["Id"].Value == currentId) { countIf++; sumIf += (decimal)r.Cells["Price"].Value; } } return (double)sumIf; } } Workaround: invalidate the affected rows manually private void radGridView1_CellValueChanged(object sender, GridViewCellEventArgs e) { if (e.Column.Name == "Price" || e.Column.Name == "Id") { foreach (GridViewRowInfo r in this.radGridView1.Rows) { if ((int)r.Cells["Id"].Value == (int)e.Row.Cells["Id"].Value) { r.InvalidateRow(); } } } }
To reproduce: - Add grid to a blank form. - Add summary rows and group descriptors. - Add rows upon a button click. - You will notice that not all rows are visible. Workaround: radGridView1.TableElement.Update(GridUINotifyAction.RowHeightChanged, null); radGridView1.TableElement.VScrollBar.Value = radGridView1.TableElement.VScrollBar.Maximum - radGridView1.TableElement.VScrollBar.LargeChange;
To reproduce: -Try to format the cell value by using html in the HTMLCellFormatting event. Resolution: You should set the ExcapeHTMLChars property of the CellElement to false in order to format the content of the cell with HTML tags. This can be done in the HTMLCellFormatting event handler of the exporter.
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]; } }
To reproduce: public Form1() { InitializeComponent(); DataTable dt = new DataTable(); DataColumn colId = new DataColumn("Id", typeof(int)); DataColumn colItem = new DataColumn("Item", typeof(string)); DataColumn colPrice = new DataColumn("Price", typeof(decimal)); dt.Columns.Add(colId); dt.Columns.Add(colItem); dt.Columns.Add(colPrice); for (int i = 0; i < 10; i++) { dt.Rows.Add(i % 5, "Item" + i, i * 2.25m); } GridViewDecimalColumn col = new GridViewDecimalColumn(); col.HeaderText = "Id"; col.Name = "Id"; col.FieldName = "Id"; radGridView1.Columns.Add(col); GridViewTextBoxColumn col1 = new GridViewTextBoxColumn(); col1.HeaderText = "Item"; col1.Name = "Item"; col1.FieldName = "Item"; radGridView1.Columns.Add(col1); GridViewMaskBoxColumn col2 = new GridViewMaskBoxColumn(); col2.HeaderText = "Price"; col2.Name = "Price"; col2.FieldName = "Price"; col2.MaskType = MaskType.Standard; col2.Mask = "###"; col2.TextMaskFormat = MaskFormat.ExcludePromptAndLiterals; radGridView1.Columns.Add(col2); radGridView1.DataSource = dt; this.radGridView1.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill; this.radGridView1.ValueChanging += radGridView1_ValueChanging; this.radGridView1.ValueChanged += radGridView1_ValueChanged; } private void radGridView1_ValueChanged(object sender, EventArgs e) { Console.WriteLine("ValueChanged"); } private void radGridView1_ValueChanging(object sender, ValueChangingEventArgs e) { Console.WriteLine("ValueChanging >> old value: " + e.OldValue + " new value: " + e.NewValue); }
To reproduce: Open Demo application >> GridView >> Export >> Export Hierarchy
To reproduce: use the following code snippet and perform the steps illustrated on the attached gif file. radGridView1.Columns.Add(new GridViewTextBoxColumn("A", "A")); radGridView1.Columns.Add(new GridViewTextBoxColumn("B", "B")); radGridView1.Columns.Add(new GridViewTextBoxColumn("C", "C")); radGridView1.Columns.Add(new GridViewTextBoxColumn("D", "D")); radGridView1.Columns.Add(new GridViewTextBoxColumn("E", "E")); radGridView1.Columns.Add(new GridViewTextBoxColumn("F", "F")); radGridView1.Columns[0].Width = 150; radGridView1.Columns[1].Width = 150; radGridView1.Columns[2].Width = 150; radGridView1.Columns[3].Width = 150; radGridView1.Columns[4].Width = 150; radGridView1.Columns[5].Width = 150; radGridView1.Rows.Add("A", "B", "C", "D", "E", "F"); radGridView1.Rows.Add("A", "B", "C", "D", "E", "F"); radGridView1.Rows.Add("A", "B", "C", "D", "E", "F"); radGridView1.Rows.Add("A", "B", "C", "D", "E", "F"); radGridView1.Rows.Add("A", "B", "C", "D", "E", "F"); radGridView1.Rows.Add("A", "B", "C", "D", "E", "F"); radGridView1.Rows.Add("A", "B", "C", "D", "E", "F"); Workaround: private void radGridView1_Resize(object sender, EventArgs e) { if (this.radGridView1.IsInEditMode) { this.radGridView1.EndEdit(); this.radGridView1.BeginEdit(); } } public class CustomGrid : RadGridView { public override string ThemeClassName { get { return typeof(RadGridView).FullName; } } protected override RadGridViewElement CreateGridViewElement() { return new CustomRadGridViewElement(); } } public class CustomRadGridViewElement : RadGridViewElement { protected override Type ThemeEffectiveType { get { return typeof(RadGridViewElement); } } protected override GridViewEditManager CreateEditorManager() { return new CustomGridViewEditManager(this); } } public class CustomGridViewEditManager : GridViewEditManager { public CustomGridViewEditManager(RadGridViewElement gridViewElement) : base(gridViewElement) { } protected override void InitializeEditor(IInputEditor activeEditor) { if (activeEditor == null) { activeEditor = this.GridViewElement.CurrentColumn.GetDefaultEditor(); this.ActiveEditor = activeEditor; } base.InitializeEditor(activeEditor); } }
To reproduce: 1. Set the RadGridView.MultiSelect property to true. 2. Set the SelectionMode = Telerik.WinControls.UI.GridViewSelectionMode.CellSelect 3. When you select multiple cells, the SelectedCells collection stores the cells in reversed order instead of keeping the selection order. Compared to GridViewSelectionMode.FullRowSelect, this behavior is different. Workaround: iterate the SelectedCells collection in reversed order
To reproduce: - Add combobox column and filter the grid so just one row is visible. - In CellValueChanged event show a message box. - Change the value in the combo box column and click in the white space of the grid. Workaround: public class MyGridComboBoxCellElement : GridComboBoxCellElement { public MyGridComboBoxCellElement(GridViewColumn column, GridRowElement row) : base(column, row) { } public override void SetContent() { if (this.ColumnInfo != null) { base.SetContent(); } } protected override Type ThemeEffectiveType { get { return typeof(GridComboBoxCellElement); } } } void radGridView1_CreateCell(object sender, GridViewCreateCellEventArgs e) { if (e.CellType == typeof(GridComboBoxCellElement)) { e.CellElement = new MyGridComboBoxCellElement(e.Column, e.Row); } }
To reproduce: private void Form1_Load(object sender, EventArgs e) { this.productsTableAdapter.Fill(this.nwindDataSet.Products); this.categoriesTableAdapter.Fill(this.nwindDataSet.Categories); radGridView1.DataSource = nwindDataSet.Categories; radGridView1.MasterTemplate.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill; GridViewTemplate template = new GridViewTemplate(); template.DataSource = nwindDataSet.Products; template.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill; radGridView1.MasterTemplate.Templates.Add(template); GridViewRelation relation = new GridViewRelation(radGridView1.MasterTemplate); relation.ChildTemplate = template; relation.RelationName = "CategoriesProducts"; relation.ParentColumnNames.Add("CategoryID"); relation.ChildColumnNames.Add("CategoryID"); radGridView1.Relations.Add(relation); this.radGridView1.CurrentRow = this.radGridView1.MasterTemplate.Templates.First().Rows[this.radGridView1.MasterTemplate.Templates.First().Rows.Count - 1]; } Workaround: this.radGridView1.MasterTemplate.ExpandAll(); this.radGridView1.MasterTemplate.CollapseAll(); this.radGridView1.CurrentRow = this.radGridView1.MasterTemplate.Templates.First().Rows[this.radGridView1.MasterTemplate.Templates.First().Rows.Count - 1]; Another scenario: if you try to add a new row to the child template on the RadButton.Click event and call the EnsureVisible(true) method, it will not affect the grid, until you expand/collapse the parent row: private void radButton1_Click(object sender, EventArgs e) { //add the new row to the child template DataRow newRow = this.nwindDataSet.Products.Rows.Add(); newRow["CategoryID"] = 3; newRow["ProductName"] = "NewProduct"; this.radGridView1.CurrentRow = this.radGridView1.MasterTemplate.Templates.First().Rows[this.radGridView1.MasterTemplate.Templates.First().Rows.Count - 1]; this.radGridView1.CurrentRow.EnsureVisible(true); } Workaround: private void radButton1_Click(object sender, EventArgs e) { //keep expanded rows List<GridViewRowInfo> expandedRows = new List<GridViewRowInfo>(); foreach (GridViewRowInfo row in this.radGridView1.Rows) { if (row.IsExpanded) { expandedRows.Add(row); } } //add the new row to the child template DataRow newRow = this.nwindDataSet.Products.Rows.Add(); newRow["CategoryID"] = 3; newRow["ProductName"] = "NewProduct"; //refresh the rows this.radGridView1.MasterTemplate.ExpandAll(); this.radGridView1.MasterTemplate.CollapseAll(); foreach (GridViewRowInfo rowToExpand in expandedRows) { rowToExpand.IsExpanded = true; } this.radGridView1.CurrentRow = null; this.radGridView1.CurrentRow = this.radGridView1.MasterTemplate.Templates.First().Rows[this.radGridView1.MasterTemplate.Templates.First().Rows.Count - 1]; this.radGridView1.CurrentRow.EnsureVisible(true); }
If a RadGridView instance is not disposed explicitly and it is left for the finalizer to dispose, a null reference exception will be thrown. This can happen if the grid is not in the control tree of a form. The exception is caused by the fact that the SelfReferenceDataProvider is disposed twice in this case.
It takes more than a minute to export 15000 cells. To reproduce: public Form1() { InitializeComponent(); //populate with data DataTable dt = new DataTable(); for (int i = 0; i < 50; i++) { dt.Columns.Add("Col" + i, typeof(string)); } DataColumn col; for (int i = 0; i < 3000; i++) { DataRow newRow = dt.Rows.Add(); for (int j = 0; j < dt.Columns.Count; j++) { col = dt.Columns[j]; newRow[col.ColumnName] = "Data." + i + " " + dt.Columns.IndexOf(col); } } this.radGridView1.DataSource = dt; this.radGridView1.BestFitColumns(Telerik.WinControls.UI.BestFitColumnMode.AllCells); } private void radButton1_Click(object sender, EventArgs e) { Telerik.WinControls.UI.Export.SpreadExport.SpreadExport spreadExporter; spreadExporter = new SpreadExport(this.radGridView1,SpreadExportFormat.Xlsx ); spreadExporter.ExportVisualSettings = false; SaveFileDialog dialog = new SaveFileDialog(); dialog.FilterIndex = 1; dialog.DefaultExt = "*.xlsx"; dialog.Filter = "Excel file |*.xlsx"; if (dialog.ShowDialog() == DialogResult.OK) { Stopwatch sw = new Stopwatch(); sw.Start(); string fileName = dialog.FileName; spreadExporter.RunExport(fileName); sw.Stop(); Console.WriteLine(string.Format("Elapsed {0}", sw.Elapsed)); Process.Start(fileName); } }
Please refer to the attached gif file. Workaround: this.radGridView1.GridBehavior = new CustomBaseGridBehavior(); public class CustomBaseGridBehavior : BaseGridBehavior { public override bool OnMouseMove(MouseEventArgs e) { GroupPanelSizeGripElement grip = this.GridViewElement.ElementTree.GetElementAtPoint(e.Location) as GroupPanelSizeGripElement; if (grip != null) { this.GridViewElement.ElementTree.Control.Cursor = Cursors.SizeNS; return true; } return base.OnMouseMove(e); } }
private void radGridView1_CellEditorInitialized(object sender, Telerik.WinControls.UI.GridViewCellEventArgs e) { GridColorPickerEditor colorEditor = e.ActiveEditor as GridColorPickerEditor; if (colorEditor!=null) { GridColorPickerElement colorPicker = colorEditor.EditorElement as GridColorPickerElement; colorPicker.ReadOnly = true; } } Please refer to the attached gif file. Workaround: private void radGridView1_EditorRequired(object sender, EditorRequiredEventArgs e) { if (e.EditorType == typeof(GridColorPickerEditor)) { e.Editor = new GridColorPickerEditor(); } }
To reproduce: - Open the Search Row sample in the demo application. - Type some text in the search textbox. - Using the context menu of the search textbox add some unicode control characters.
It would be great if multi-page printing is supported for grids with ColumnGroupsViewDefinition and HtmlViewDefinition.