To reproduce: - Add one-to-many relations hierarchy 3 or more child templates. - Export the grid using GridViewSpreadExport - The child rows of the last parent row are missing. Workaround: Add an empty parent row at the end of the grid.
To reproduce: Sub New() InitializeComponent() Dim dt As New DataTable() dt.Columns.Add("Price", GetType(System.Double)) dt.Columns.Add("Name", GetType(System.String)) dt.Columns.Add("Nr", GetType(System.Double)) For i As Integer = 0 To 49 dt.Rows.Add(i, "Data" & i, i) Next With Me.RadGridView1 .DataSource = dt .Columns("Price").FormatString = "{0:C2}" .Columns("Nr").FormatString = "{0:N1}" .Columns("Price").ExcelExportType = Export.DisplayFormatType.Currency ' .AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill End With Me.RadGridView1.Columns("Price").ExcelExportType = Export.DisplayFormatType.Currency Me.RadGridView1.Columns("Nr").ExcelExportType = Export.DisplayFormatType.Custom Me.RadGridView1.Columns("Nr").ExcelExportFormatString = "{0:N1}" Me.RadGridView1.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill End Sub Private Sub RadButton1_Click(sender As Object, e As EventArgs) Handles RadButton1.Click Dim spreadStreamExport As New GridViewSpreadStreamExport(Me.RadGridView1) spreadStreamExport.ExportVisualSettings = True Dim fileName As String = "..\..\" + DateTime.Now.ToLongTimeString().Replace(":", "_").ToString() + ".xlsx" spreadStreamExport.RunExport(fileName, New SpreadStreamExportRenderer()) Process.Start(fileName) End Sub Workaround: Me.RadGridView1.Columns("Nr").ExcelExportType = Export.DisplayFormatType.Fixed AddHandler spreadStreamExport.CellFormatting, AddressOf CellFormatting Private Sub CellFormatting(sender As Object, e As SpreadStreamCellFormattingEventArgs) If e.ExportCell.ColumnIndex = 2 Then e.ExportCell.ExportFormat = "0.0" End If End Sub
The specified format in the DisplayFormat attribute should be considered when automatically generating the GridViewDateTimeColumn. public RadForm1() { InitializeComponent(); List<Item> items = new List<Item>(); for (int i = 0; i < 5; i++) { items.Add(new Item(DateTime.Now.AddDays(i))); } this.radGridView1.DataSource = items; this.radGridView1.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill; } public class Item { [System.ComponentModel.DisplayName("My Date")] [System.ComponentModel.DataAnnotations.DisplayFormat(DataFormatString = "{0:MM/dd/yyyy}")] public DateTime Date { get; set; } public Item(DateTime date) { this.Date = date; } }
To reproduce: please refer to the attached gif file and sample project. The multiple newly added rows are selected only when the grid is not sorted. Workaround: use Begin/EndUpdate when adding multiple rows private void radButton1_Click(object sender, EventArgs e) { this.radGridView1.ClearSelection(); this.radGridView1.BeginUpdate(); for (int i = 0; i < 3; i++) { GridViewDataRowInfo row = new GridViewDataRowInfo(this.radGridView1.MasterView); row.IsSelected = true; row.IsCurrent = true; row.Cells["Id"].Value = this.radGridView1.Rows.Count; row.Cells["Name"].Value = "Row" + row.Cells["Id"].Value; this.radGridView1.Rows.Add(row); } this.radGridView1.EndUpdate(); }
To reproduce: 1. Use the following code: public Form1() { InitializeComponent(); this.radGridView1.EnableFiltering = true; GridViewDecimalColumn col = new GridViewDecimalColumn(); col.Name = "Calculated Column"; col.HeaderText = "Order value"; radGridView1.Columns.Add(col); radGridView1.Columns["Calculated Column"].Expression = "Freight/Sum(Freight)"; } private void Form1_Load(object sender, EventArgs e) { this.ordersTableAdapter.Fill(this.nwindDataSet.Orders); this.radGridView1.DataSource = this.ordersBindingSource; this.radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill; GridViewSummaryItem summaryItem = new GridViewSummaryItem(); summaryItem.Name = "Freight"; summaryItem.Aggregate = GridAggregateFunction.Sum ; GridViewSummaryRowItem summaryRowItem = new GridViewSummaryRowItem(); summaryRowItem.Add(summaryItem); this.radGridView1.SummaryRowsTop.Add(summaryRowItem); this.radGridView1.SummaryRowsBottom.Add(summaryRowItem); } 2. Filter the grid by EmployeeID for example. You will notice that the summary item for Freight is recalculated considering the filtered rows. However, the calculated column doesn't update its values.
To reproduce: Sub New() InitializeComponent() Dim dt As New DataTable dt.Columns.Add("Id", GetType(Integer)) dt.Columns.Add("Name", GetType(String)) For index = 1 To 200000 dt.Rows.Add(index, "Item" & index) Next Me.RadGridView1.DataSource = dt Me.RadGridView1.MultiSelect = True Me.RadGridView1.SelectionMode = Telerik.WinControls.UI.GridViewSelectionMode.CellSelect End Sub Private Sub RadButton1_Click(sender As Object, e As EventArgs) Handles RadButton1.Click Dim sw As New Stopwatch sw.Start() Dim mi As MethodInfo = GetType(GridViewSelectedCellsCollection).GetMethod("BeginUpdate", BindingFlags.Instance Or BindingFlags.NonPublic) mi.Invoke(Me.RadGridView1.MasterTemplate.SelectedCells, Nothing) For Each row As GridViewDataRowInfo In Me.RadGridView1.Rows row.Cells("Name").IsSelected = True Next Dim mi2 As MethodInfo = GetType(GridViewSelectedCellsCollection).GetMethod("EndUpdate", BindingFlags.Instance Or BindingFlags.NonPublic) mi2.Invoke(Me.RadGridView1.MasterTemplate.SelectedCells, New Object() {True}) sw.Stop() RadMessageBox.Show(sw.ElapsedMilliseconds) End Sub
To reproduce: - Create load on demand hierarchy. - Open the excel filter popup. - The RowSourceNeeded event fires for all rows. Workaround: public class MyGridHeaderCellElement : GridHeaderCellElement { public MyGridHeaderCellElement(GridViewDataColumn col, GridRowElement row) : base(col, row) { } protected override Type ThemeEffectiveType { get { return typeof(GridHeaderCellElement); } } protected override IGridFilterPopup CreateFilterPopup() { this.GridControl.Tag = "FileterInitializing"; return base.CreateFilterPopup(); } } // in the main forms you cab skip the event code execution while the popup is initialized private void RadGridView1_FilterPopupInitialized(object sender, FilterPopupInitializedEventArgs e) { this.radGridView1.Tag = null; } private void RadGridView1_CreateCell(object sender, GridViewCreateCellEventArgs e) { if (object.ReferenceEquals(e.CellType, typeof(GridHeaderCellElement))) { e.CellType = typeof(MyGridHeaderCellElement); } } void radGridView1_RowSourceNeeded(object sender, GridViewRowSourceNeededEventArgs e) { if (radGridView1.Tag != null && radGridView1.Tag == "FileterInitializing") { return; } //other code }
To reproduce: please refer o the attached sample project: 1.Click the left button. A new row will be added to the left grid and the grid will scroll to it. 2. Move the scrollbar back to the top and sort the ID column. 3. Click the left button again. A new row will be added but the grid won't scroll to it. Perform the same steps with the right grid. The grid scrolls as expected when you add a new row in a sorted grid. Workaround: use the Rows.Add method instead of Rows.AddNew.
To reproduce: The attached video shows how you can reproduce this. Workaround: Use the Properties window to remove summary rows.
To reproduce: please refer to the attached sample project and gif file. Workaround: private void radGridView1_CellEditorInitialized(object sender, GridViewCellEventArgs e) { RadDateTimeEditor editor = e.ActiveEditor as RadDateTimeEditor; if (editor != null) { RadDateTimeEditorElement el = editor.EditorElement as RadDateTimeEditorElement; if (el != null) { el.TextBoxElement.TextBoxItem.GotFocus -= TextBoxItem_GotFocus; el.TextBoxElement.TextBoxItem.GotFocus += TextBoxItem_GotFocus; } } } private void TextBoxItem_GotFocus(object sender, EventArgs e) { RadTextBoxItem tb = sender as RadTextBoxItem; if (tb != null) { tb.SelectionLength = 0; } }
To reproduce: public RadForm1() { InitializeComponent(); this.radGridView1.MasterTemplate.Columns.Add(new GridViewDecimalColumn("ParentId")); this.radGridView1.MasterTemplate.Columns.Add(new GridViewTextBoxColumn("ParentName")); this.radGridView1.MasterTemplate.Rows.Add(1, "Item" + 1); this.radGridView1.MasterTemplate.Rows.Add(2, "Item" + 2); this.radGridView1.MasterTemplate.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill; for (int i = 0; i < 10; i++) { GridViewTemplate template = new GridViewTemplate(); template.AllowAddNewRow = false; template.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill; template.Caption = "Tab" + i; template.Columns.Add(new GridViewDecimalColumn("Id")); template.Columns.Add(new GridViewTextBoxColumn("Name")); this.radGridView1.MasterTemplate.Templates.Add(template); template.HierarchyDataProvider = new GridViewEventDataProvider(template); } this.radGridView1.RowSourceNeeded += radGridView1_RowSourceNeeded; } private void radGridView1_RowSourceNeeded(object sender, GridViewRowSourceNeededEventArgs e) { for (int i = 0; i < 10; i++) { GridViewRowInfo row = e.Template.Rows.NewRow(); row.Cells["Id"].Value = e.ParentRow.Cells["ParentId"].Value; row.Cells["name"].Value = "child row" + i; e.SourceCollection.Add(row); } } private void radGridView1_ViewCellFormatting(object sender, CellFormattingEventArgs e) { GridDetailViewCellElement cell = e.CellElement as GridDetailViewCellElement; if (cell != null) { RadPageViewStripElement strip = cell.PageViewElement as RadPageViewStripElement; strip.StripButtons = StripViewButtons.LeftScroll | StripViewButtons.RightScroll; } } If you have just one row on the master level, the strip buttons don't navigate the tabs. Workaround: add a dummy row that is hidden: private void radGridView1_RowFormatting(object sender, RowFormattingEventArgs e) { if (e.RowElement.RowInfo == this.radGridView1.Rows.Last()) { e.RowElement.RowInfo.Height = 1; e.RowElement.RowInfo.MinHeight = 1; e.RowElement.RowInfo.MaxHeight = 1; } else { e.RowElement.RowInfo.Height = 25; e.RowElement.RowInfo.MinHeight = 25; e.RowElement.RowInfo.MaxHeight = 25; } }
Workaround: custom CompositeFilterForm private void radGridView1_CreateCompositeFilterDialog(object sender, GridViewCreateCompositeFilterDialogEventArgs e) { e.Dialog = new MyCompositeFilterForm(); } public class MyCompositeFilterForm : CompositeFilterForm { public override void Initialize(GridViewDataColumn dataColumn, Telerik.WinControls.Data.FilterDescriptor filterDescriptor, bool useTypedEditors) { base.Initialize(dataColumn, filterDescriptor, useTypedEditors); if (dataColumn.Name == "Time") { RadDateTimePicker rEditor = (RadDateTimePicker)this.RightEditor; rEditor.DateTimePickerElement.ShowTimePicker = true; rEditor.DateTimePickerElement.CalendarSize = new Size(500, 250); RadDateTimePicker lEditor = (RadDateTimePicker)this.LeftEditor; lEditor.DateTimePickerElement.ShowTimePicker = true; lEditor.DateTimePickerElement.CalendarSize = new Size(500, 250); } } protected override void OnClosing(System.ComponentModel.CancelEventArgs e) { base.OnClosing(e); if (this.DialogResult == DialogResult.OK) { object leftValue = this.GetValueFromDateEditor(this.LeftEditor); if (leftValue != null) { this.LeftDescriptor.Value = leftValue; } object rightValue = this.GetValueFromDateEditor(this.RightEditor); if (rightValue != null) { this.RightDescriptor.Value = rightValue; } } } protected virtual object GetValueFromDateEditor(RadControl editorControl) { object value = null; if (editorControl is RadDateTimePicker) { value = ((RadDateTimePicker)editorControl).Value; return value; } return value; } }
The issue can be reproduced with the .40 version of the assemblies and in a scenario in which the grid is added as a RadMenuHostItem to the Items collection of a drop-down button. Workaround: set the BindingContext of the grid to equal that of the form: public Form1() { InitializeComponent(); radGridView1.BindingContext = this.BindingContext; }
To reproduce: public Form1() { InitializeComponent(); radGridView1.Columns.Add(new GridViewTextBoxColumn("Text1")); radGridView1.Columns.Add(new GridViewTextBoxColumn("Text2")); radGridView1.Columns.Add(new GridViewTextBoxColumn("Text3")); radGridView1.Columns.Add(new GridViewTextBoxColumn("Text4")); radGridView1.Columns.Add(new GridViewTextBoxColumn("Text5")); radGridView1.Columns.Add(new GridViewTextBoxColumn("Text6")); radGridView1.Columns.Add(new GridViewTextBoxColumn("Text7")); radGridView1.Columns.Add(new GridViewTextBoxColumn("Text8")); radGridView1.Columns.Add(new GridViewDateTimeColumn("Date1")); radGridView1.Columns.Add(new GridViewDecimalColumn("Amount1")); radGridView1.Columns.Add(new GridViewDecimalColumn("Amount2")); radGridView1.Columns.Add(new GridViewDecimalColumn("Amount3")); radGridView1.Columns.Add(new GridViewDecimalColumn("Amount4")); radGridView1.Columns.Add(new GridViewDecimalColumn("Amount5")); radGridView1.Columns.Add(new GridViewDecimalColumn("Amount6")); radGridView1.DataSource = GetDataSet(); } private DataTable GetDataSet() { DataTable dt = new DataTable(); dt.Columns.Add(new DataColumn("Text1", typeof(string))); dt.Columns.Add(new DataColumn("Text2", typeof(string))); dt.Columns.Add(new DataColumn("Text3", typeof(string))); dt.Columns.Add(new DataColumn("Text4", typeof(string))); dt.Columns.Add(new DataColumn("Text5", typeof(string))); dt.Columns.Add(new DataColumn("Text6", typeof(string))); dt.Columns.Add(new DataColumn("Text7", typeof(string))); dt.Columns.Add(new DataColumn("Text8", typeof(string))); dt.Columns.Add(new DataColumn("Date1", typeof(DateTime))); dt.Columns.Add(new DataColumn("Amount1", typeof(decimal))); dt.Columns.Add(new DataColumn("Amount2", typeof(decimal))); dt.Columns.Add(new DataColumn("Amount3", typeof(decimal))); dt.Columns.Add(new DataColumn("Amount4", typeof(decimal))); dt.Columns.Add(new DataColumn("Amount5", typeof(decimal))); dt.Columns.Add(new DataColumn("Amount6", typeof(decimal))); for (int i = 1; i <= 150000; i++) { dt.Rows.Add(new object[] { "Example Text For Row " + i.ToString(), "Example Text For Row " + i.ToString(), "More Example Text For Row " + i.ToString(), "Even More Example Text For Row " + i.ToString(), "Lots More Example Text For Row " + i.ToString(), "Excessive Example Text For Row " + i.ToString(), "Extra Example Text For Row " + i.ToString(), "Random Example Text For Row " + i.ToString(), new DateTime(2015, i % 12 + 1, i % 28 + 1), i % 2 * 10000, i % 3 * 10000, i % 5 * 10000, i % 7 * 10000, i % 11 * 10000, i % 13 * 10000 }); } return dt; } string fileName = @"..\..\" + DateTime.Now.ToLongTimeString().Replace(":", "_"); private void button1_Click(object sender, EventArgs e) { SaveFileDialog sfdExportToExcel = new SaveFileDialog(); DialogResult exportBrowse = sfdExportToExcel.ShowDialog(); if (exportBrowse == DialogResult.OK) { GridViewSpreadExport exporter = new GridViewSpreadExport(this.radGridView1); exporter.SheetMaxRows = Telerik.WinControls.UI.Export.ExcelMaxRows._1048576; exporter.FileExportMode = FileExportMode.CreateOrOverrideFile; exporter.ExportVisualSettings = false; exporter.AsyncExportCompleted += exporter_AsyncExportCompleted; SpreadExportRenderer renderer = new SpreadExportRenderer(); exporter.RunExportAsync(fileName, renderer); } }
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: 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();
To reproduce: private void Form1_Load(object sender, EventArgs e) { this.order_DetailsTableAdapter.Fill(this.nwindDataSet.Order_Details); this.radGridView1.DataSource = this.orderDetailsBindingSource; this.radGridView1.EnablePaging = true; this.radGridView1.AutoSizeRows = true; } private void radButton1_Click(object sender, EventArgs e) { this.radGridView1.PrintStyle.PrintAllPages = true; this.radGridView1.PrintPreview(); } Workaround: refresh the MasterTemplate after the PrintPreview dialog is closed: this.radGridView1.PrintPreview(); this.radGridView1.MasterTemplate.Refresh();
To reproduce: public RadForm1() { InitializeComponent(); DataTable dt = new DataTable(); for (int i = 0; i < 10; i++) { dt.Columns.Add("Col" + i); } for (int i = 0; i < 50; i++) { DataRow dr = dt.NewRow(); foreach (DataColumn col in dt.Columns) { dr[col.ColumnName] = "Data." + i + "." + dt.Columns.IndexOf(col); } dt.Rows.Add(dr); } this.radGridView1.DataSource = dt; this.radGridView1.MasterTemplate.EnablePaging = true; this.radGridView1.MasterTemplate.ShowGroupedColumns = true; } public void ExportContactToExcelFile(string strFileName) { GridViewSpreadExport spreadExporter = new GridViewSpreadExport(this.radGridView1); SpreadExportRenderer exportRenderer = new SpreadExportRenderer(); spreadExporter.PagingExportOption = PagingExportOption.AllPages; spreadExporter.ExportVisualSettings = true; spreadExporter.SheetName = "Contacts"; spreadExporter.RunExport(strFileName, exportRenderer); } private void radButton1_Click(object sender, EventArgs e) { ExportContactToExcelFile(@"..\..\Export" + DateTime.Now.ToLongTimeString().Replace(":", "_") + ".xlsx"); } Workaround: refresh the MasterTemplate after the export: private void radButton1_Click(object sender, EventArgs e) { ExportContactToExcelFile(@"..\..\Export" + DateTime.Now.ToLongTimeString().Replace(":", "_") + ".xlsx"); this.radGridView1.MasterTemplate.Refresh(); }
Workaround: skip the summary rows by creating custom GridViewSearchRowInfo: private void radGridView1_CreateRowInfo(object sender, GridViewCreateRowInfoEventArgs e) { if (e.RowInfo is GridViewSearchRowInfo) { e.RowInfo = new CustomGridViewSearchRowInfo(e.ViewInfo); } } public class CustomGridViewSearchRowInfo : GridViewSearchRowInfo { public CustomGridViewSearchRowInfo(GridViewInfo viewInfo) : base(viewInfo) { } protected override bool MatchesSearchCriteria(string searchCriteria, GridViewRowInfo row, GridViewColumn col) { if (row is GridViewSummaryRowInfo) { return false; } return base.MatchesSearchCriteria(searchCriteria, row, col); } }