To reproduce: 1. Add a RadGridView with two GridViewMultiComboBoxColumns at design time. 2. Bind both of the columns at design time to two different data sources. 3. In the CellEditorInitialized event, set the RadMultiColumnComboBoxElement.AutoSizeDropDownToBestFit property to true. 4. Run the application and open the editor for one of the GridViewMultiComboBoxColumns . You will notice that the columns are automatically sized to fit the content. However, if you open the editor for the other GridViewMultiComboBoxColumn, you will see that columns are not auto sized correctly. Please refer to the attached gif file. Workaround: private void radGridView1_CellEditorInitialized(object sender, Telerik.WinControls.UI.GridViewCellEventArgs e) { RadMultiColumnComboBoxElement mccbEditor = e.ActiveEditor as RadMultiColumnComboBoxElement; if (mccbEditor != null) { mccbEditor.AutoSizeDropDownToBestFit = true; mccbEditor.PopupOpening -= mccbEditor_PopupOpening; mccbEditor.PopupOpening += mccbEditor_PopupOpening; } } private void mccbEditor_PopupOpening(object sender, CancelEventArgs e) { RadMultiColumnComboBoxElement mccbEditor = sender as RadMultiColumnComboBoxElement; if (mccbEditor != null) { mccbEditor.EditorControl.BestFitColumns(BestFitColumnMode.AllCells); int width = 0; foreach (GridViewColumn c in mccbEditor.EditorControl.Columns) { width += c.Width; } width += mccbEditor.EditorControl.TableElement.VScrollBar.Size.Width; mccbEditor.MultiColumnPopupForm.Size = new Size(width, mccbEditor.MultiColumnPopupForm.Size.Height); } }
The row's MaxHeight property does not affect the row sizing when the AutoSizeRows property of RadGridView is enabled. Workaround: Use the following data row: public class MyGridDataRowElement : GridDataRowElement { protected override Type ThemeEffectiveType { get { return typeof(GridDataRowElement); } } protected override System.Drawing.SizeF MeasureCore(System.Drawing.SizeF availableSize) { float maxHeight = this.RowInfo.MaxHeight; bool isAutoSize = this.GridViewElement.AutoSize && this.RowInfo.MaxHeight > 0 && availableSize.Height == float.PositiveInfinity; SizeF size = base.MeasureCore(availableSize); if (isAutoSize && size.Height > maxHeight) { availableSize.Height = maxHeight; size = base.MeasureCore(availableSize); } return size; } } here is how to replace it and set the max height: void radGridView1_RowFormatting(object sender, RowFormattingEventArgs e) { e.RowElement.RowInfo.MaxHeight = 32; } void radGridView1_CreateRow(object sender, GridViewCreateRowEventArgs e) { if (e.RowType == typeof(GridDataRowElement)) { e.RowType = typeof(MyGridDataRowElement); } }
How can I enter the Value "" (empty string) in the traditional filter system (not Excel like filter).
The grid does not seem to accept an empty string as an argument to "Equals" through the UI.
Ideally I would like to extend the standard filter menu in traditional filtering (and the filter operator drop down in custom filtering dialog) to contain operators "Is Empty" "Is Not Empty" and "Is Null Or Empty", "Is Not Null And Not Empty"
Regards
Erwin
To reproduce: please refer to the attached sample project and follow the steps from the attached gif file. 1. Run the project and type "hana" in the second filter cell. You will notice that after a few seconds the input is handled and the grid is filtered. Workaround: use RadVirtualGrid instead. https://docs.telerik.com/devtools/winforms/virtualgrid/overview https://docs.telerik.com/devtools/winforms/virtualgrid/filtering/filtering Second workaround: https://docs.telerik.com/devtools/winforms/gridview/filtering/how-to/filter-on-enter
The performance of excel-like filtering when you have more than 5000+ row in RadGridView.
Currently, if there are not enough rows to fill the height of RadGridView control, the pinned row will appear right after the last row. It will be good to facilitate customization that sets the pinned row to appear at the bottom of the grid. Same logic holds for summary rows and columns. Workaround: public Form1() { InitializeComponent(); DataTable dt = new DataTable(); dt.Columns.Add("Id"); dt.Columns.Add("Name"); for (int i = 0; i < 5; i++) { dt.Rows.Add(i, "Item" + i); } this.radGridView1.DataSource = dt; this.radGridView1.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill; this.radGridView1.AllowSearchRow = true; this.radGridView1.SearchRowPosition = Telerik.WinControls.UI.SystemRowPosition.Bottom; this.radGridView1.ViewDefinition = new CustomTableViewDefition(); } public class CustomTableViewDefition : TableViewDefinition { public override IRowView CreateViewUIElement(GridViewInfo viewInfo) { return new CustomTableElement(); } } public class CustomTableElement : GridTableElement { protected override RowsContainerElement CreateViewElement() { return new CustomRowsContainerElement(); } } public class CustomRowsContainerElement : RowsContainerElement { protected override SizeF ArrangeOverride(SizeF finalSize) { float y = 0; this.TopPinnedRows.Arrange(new RectangleF(0, y, finalSize.Width, this.TopPinnedRows.DesiredSize.Height)); y += this.TopPinnedRows.DesiredSize.Height + ElementSpacing; this.ScrollableRows.Arrange(new RectangleF(0, y, finalSize.Width, this.ScrollableRows.DesiredSize.Height)); y += this.ScrollableRows.DesiredSize.Height + ElementSpacing; this.BottomPinnedRows.Arrange(new RectangleF(0, finalSize.Height - this.BottomPinnedRows.DesiredSize.Height, finalSize.Width, this.BottomPinnedRows.DesiredSize.Height)); return finalSize; } }
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: DataTable table; public RadForm1() { InitializeComponent(); table = GetTable(); radGridView1.DataSource = table; } private void radButton1_Click(object sender, EventArgs e) { var changes = table.GetChanges(); if (changes == null) { Console.WriteLine("No Changes"); } else { Console.WriteLine("Saved"); foreach (DataRow item in changes.Rows) { Console.WriteLine(item.RowState.ToString()); } } table.AcceptChanges(); } static DataTable GetTable() { DataTable table = new DataTable(); table.Columns.Add("Dosage", typeof(int)); table.Columns.Add("Drug", typeof(string)); table.Columns.Add("Name", typeof(string)); table.Columns.Add("Date", typeof(DateTime)); table.Rows.Add(25, "Indocin", "David", DateTime.Now); table.Rows.Add(50, "Enebrel", "Sam", DateTime.Now); table.Rows.Add(10, "Hydralazine", "Christoff", DateTime.Now); table.Rows.Add(21, "Combivent", "Janet", DateTime.Now); table.Rows.Add(100, "Dilantin", "Melanie", DateTime.Now); table.AcceptChanges(); return table; } Workaround: (this.radGridView1.CurrentRow.DataBoundItem as IEditableObject).EndEdit();
Presently it is not possible to persist customer created formatting objects in RadGridView.
To reproduce: void radGridView1_CurrentRowChanged(object sender, Telerik.WinControls.UI.CurrentRowChangedEventArgs e) { e.CurrentRow.Cells[2].ColumnInfo.IsCurrent = true; }
ADD. RadGridView - add the ability to group by a certain column and display the groups sorted by the values of another column
If you set the MinWidth and MaxWidth to a column and then set AutoSizeColumnMode to Fill (all this in the form constructor) a gap will appear between the columns. Workaround: set the Fill before the MinWidth and MaxWidth and to do all these operations on Load.
Hello,
We are experiencing a strange behaviour of RadGridView set as a self referencing hierarchy when used with Excel filters.
Once we use predefined filter values (both, build-in and custom defined by us) the filter icon is highlitghted when none of the filter is marked. This higlight can be removed when clear filters button of filter popup is used or FilterDescriptors are cleared. If we do not clear the filters manually, and, for instance, sort grid column the application crashes with internal error of the grid. Error reads Object reference not set to an instance of object.
Attached movie will explain it better. I have also attached a ver simple sample project with data (which does not make sense, just for visualisation) that should fail when you repeat steps described above (turn today or last 7 days filter, apply, select no filter, apply and try to sort the same column).
Is there a workaround or specific conditions we need to apply to have it working?
Thanks for your advice.
I'm also attaching errors details:
Consider the iTunes Artist mode grid http://www.telerik.com/forums/itunes-like-grid
To reproduce: Add a RadGridView and use the following code. When you expand the first row, the vertical scrollbar is not correct. Scrolling down changes its size. However, if you expand the last row, it takes few seconds to open. Second scenario: In addition of the following code, if you change the TableElement.PageViewMode to PageViewMode.ExplorerBar, expanding the first row takes few seconds to load the hierarchical data as well. public partial class Form1 : Form { public Form1() { InitializeComponent(); List<Item> items = new List<Item>(); List<SubItem> subItems = new List<SubItem>(); for (int i = 1; i <= 3; i++) { Item item = new Item(i, "Item" + i); for (int j = 1000; j <= 2010; j++) { subItems.Add(new SubItem(j, "SubItem" + j, i)); } items.Add(item); } this.radGridView1.DataSource = items; this.radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill; GridViewTemplate template = new GridViewTemplate(); template.ReadOnly = true; template.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill; GridViewRelation relation = new GridViewRelation(this.radGridView1.MasterTemplate, template); relation.ParentColumnNames.Add("Id"); relation.ChildColumnNames.Add("ItemId"); this.radGridView1.MasterTemplate.Templates.Add(template); this.radGridView1.Relations.Add(relation); template.DataSource = subItems; } } public class Item { public int Id { get; set; } public string Title { get; set; } public Item(int id, string title) { this.Id = id; this.Title = title; } } public class SubItem { public int Id { get; set; } public int ItemId { get; set; } public string Name { get; set; } public SubItem(int id, string name, int itemId) { this.Id = id; this.ItemId = itemId; this.Name = name; } }
Steps to reproduce: 1. Use the RadGridView Smart Tag to set its data source 2. Press "Add Project DataSource" 3. Select "Object" 4. Drill down and select the class you created. (see below) 5. Select the New Data Source 6. Run the project Code to reproduce: public class TestClass { public enum Month { January, Febuary, March, April, May, June, July, August, September, October, November, December } public Month TestMonth {get; set;} public String TestMessage {get; set;} public TestClass(Month month, String message) { TestMonth = month; TestMessage = message; } } Workaround: Use BindingList instead System.Windows.Forms.BindingSource.
Use attached project to reproduce! Another case is when the font size is changed from the settings dialog - in this case, the row height is not adjusted. Workaround: Use the following custom print style: class MyTableViewDefinitionPrintRenderer : TableViewDefinitionPrintRenderer { public MyTableViewDefinitionPrintRenderer(RadGridView grid) : base(grid) { } protected override int GetDataRowHeight(GridViewRowInfo row, TableViewRowLayoutBase rowLayout) { int result = base.GetDataRowHeight(row, rowLayout); int newHeight = 0; if (!(row is GridViewGroupRowInfo)) { foreach (GridViewColumn col in row.ViewTemplate.Columns) { if (col is GridViewRowHeaderColumn || col is GridViewIndentColumn || !col.IsVisible) { continue; } string value = row.Cells[col.Name].Value.ToString(); TableViewCellArrangeInfo info = ((TableViewRowLayout)rowLayout).LayoutImpl.GetArrangeInfo(col); float cellWidth = (float)info.CachedWidth; int currentHeight = TextRenderer.MeasureText(value, this.GridView.PrintStyle.CellFont, new Size((int)cellWidth, 0), TextFormatFlags.WordBreak).Height + this.GridView.Font.Height *4; newHeight = Math.Max(newHeight, currentHeight); } } return Math.Max(newHeight, result); } } class MyPrintStyle :GridPrintStyle { protected override BaseGridPrintRenderer InitializePrintRenderer(RadGridView grid) { return new MyTableViewDefinitionPrintRenderer(grid); } }
To reproduce: use the following code snippet, save the layout and load it afterwards. You will notice that only the master and the first child template are successfully loaded. public Form1() { InitializeComponent(); DataTable dt = new DataTable(); dt.Columns.Add("Id", typeof(int)); dt.Columns.Add("Name", typeof(string)); for (int i = 0; i < 5; i++) { dt.Rows.Add(i, "Parent" + i); } this.radGridView1.MasterTemplate.DataSource = dt; this.radGridView1.MasterTemplate.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill; //child level 1 GridViewTemplate template = new GridViewTemplate(); template.DataSource = GetData(5, 20, 0, 5); template.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill; radGridView1.MasterTemplate.Templates.Add(template); GridViewRelation relation = new GridViewRelation(radGridView1.MasterTemplate); relation.ChildTemplate = template; relation.RelationName = "ParentChild"; relation.ParentColumnNames.Add("Id"); relation.ChildColumnNames.Add("ParentId"); radGridView1.Relations.Add(relation); //child level 2 GridViewTemplate template2 = new GridViewTemplate(); template2.DataSource = GetData(20, 40, 5, 20); template2.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill; template.Templates.Add(template2); GridViewRelation relation2 = new GridViewRelation(template); relation2.ChildTemplate = template2; relation2.RelationName = "ParentChild"; relation2.ParentColumnNames.Add("Id"); relation2.ChildColumnNames.Add("ParentId"); radGridView1.Relations.Add(relation2); //child level 3 GridViewTemplate template3 = new GridViewTemplate(); template3.DataSource = GetData(40, 100, 20, 40); template3.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill; template2.Templates.Add(template3); GridViewRelation relation3 = new GridViewRelation(template2); relation3.ChildTemplate = template3; relation3.RelationName = "ParentChild"; relation3.ParentColumnNames.Add("Id"); relation3.ChildColumnNames.Add("ParentId"); radGridView1.Relations.Add(relation3); //child level 4 GridViewTemplate template4 = new GridViewTemplate(); template4.DataSource = GetData(100, 200, 40, 100); template4.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill; template3.Templates.Add(template4); GridViewRelation relation4 = new GridViewRelation(template3); relation4.ChildTemplate = template4; relation4.RelationName = "ParentChild"; relation4.ParentColumnNames.Add("Id"); relation4.ChildColumnNames.Add("ParentId"); radGridView1.Relations.Add(relation4); } private object GetData(int from, int to, int parentFrom, int parentTo) { DataTable dt = new DataTable(); dt.Columns.Add("Id", typeof(int)); dt.Columns.Add("Name", typeof(string)); dt.Columns.Add("ParentId", typeof(int)); Random rand = new Random(); for (int i = from; i < to; i++) { dt.Rows.Add(i, "Child" + i, rand.Next(parentFrom, parentTo)); } return dt; } private void radButton1_Click(object sender, EventArgs e) { string s = "default.xml"; SaveFileDialog dialog = new SaveFileDialog(); dialog.Filter = "xml files (*.xml)|*.xml|All files (*.*)|*.*"; dialog.Title = "Select a xml file"; if (dialog.ShowDialog() == DialogResult.OK) { s = dialog.FileName; } this.radGridView1.SaveLayout(s); } private void radButton2_Click(object sender, EventArgs e) { string s = "default.xml"; OpenFileDialog dialog = new OpenFileDialog(); dialog.Filter = "xml files (*.xml)|*.xml|All files (*.*)|*.*"; dialog.Title = "Select a xml file"; if (dialog.ShowDialog() == DialogResult.OK) { s = dialog.FileName; } this.radGridView1.LoadLayout(s); } Workaround: grid templates for the inner levels are recreated after loading the layout. Their DataSource is null and the existing relations points to the old templates. Clear the relations and setup them again with the new child template instances.
Steps to reproduce: 1. Create a form 2. Set its Localization property to true. 3. Add RadGridView to the form 4. Add 3 GridViewTextBoxColumn instances at design-time 5. Change the Language of the form to Polish 6. The variable names of the columns are changed (gridViewTextBoxColumn1 to gridViewTextBoxColumn4, gridViewTextBoxColumn2 to gridViewTextBoxColumn5, gridViewTextBoxColumn3 to gridViewTextBoxColumn6)