To reproduce: please refer to the attached sample gif file. Note that it is important that the child template is bound at design time and the columns are automatically generated. Workaround: setup the ViewDefinition programmatically:
To reproduce: run the attached sample project. Type "chef" in the search box and then try to sort some of the columns. Click the header cell several times and as a result the exception will occur. Workaround: public class CustomGrid : RadGridView { public new object DataSource { get { return (object)base.DataSource; } set { GridViewSearchRowInfo.Cancel = true; Thread.Sleep(100); base.DataSource = null; this.EnableFiltering = false; base.DataSource = value; this.EnableFiltering = true; base.CurrentRow = null; } } }
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: run the attached sample project and click the 'export' button. The exported file fill be automatically opened. If you select several cells from the UnitPrice column you will see at the bottom that the cell values ' total is displayed. However, if you include the summary item's value in the selection its value is not taken into consideration. If you pay attention to the cell's format, it will be General instead of custom numeric one. Workaround: Private Sub spreadExporter_CellFormatting(sender As Object, e As Telerik.WinControls.Export.CellFormattingEventArgs) If e.GridRowInfoType = GetType(GridViewSummaryRowInfo) AndAlso e.GridCellInfo.ColumnInfo.Name = "DecimalColumn" Then Dim cellSelection As CellSelection = TryCast(e.CellSelection, CellSelection) Dim cellFormat As New CellValueFormat("### ### ###.00") If cellFormat IsNot Nothing Then cellSelection.SetValue(Decimal.Parse(cellSelection.GetValue().Value.RawValue.Replace(" ", ""))) cellSelection.SetFormat(cellFormat) End If End If End Sub
To reproduce, perform the following steps with the attached project: Step 1: Create Sample Database ============================== New (Sample1.db) Import Save Close Step 2: ====== Open (Sample1.db) Import Save Close Step 3: ====== New (Sample2.db) Import (Exception) Workaround: radGridView1.GridViewElement.Navigator = new MyNavigator(); class MyNavigator : BaseGridNavigator { public override bool SelectLastRow() { var enumerator = typeof(BaseGridNavigator).GetField("enumerator", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(this) as GridTraverser; enumerator.Reset(); return base.SelectLastRow(); } }
To reproduce: DataTable dt = new DataTable(); dt.Columns.Add("Id", typeof(int)); dt.Columns.Add("Name", typeof(string)); dt.Columns.Add("NumberAsShort", typeof(ushort)); for (int i = 0; i < 100; i++) { dt.Rows.Add(i, "Row" + i, i ); } this.radGridView1.DataSource = dt; Workaround: use the CellFormatting event https://docs.telerik.com/devtools/winforms/gridview/cells/formatting-cells
Workaround: adjust the cell/row spacing this.radGridView1.TableElement.CellSpacing = -2; this.radGridView1.TableElement.RowSpacing = -2;
Workaround: private void radGridView1_CellFormatting(object sender, Telerik.WinControls.UI.CellFormattingEventArgs e) { GridDataCellElement cell = e.CellElement as GridDataCellElement ; if (cell!=null && cell.SelfReferenceLayout!=null) { foreach (RadElement item in cell.SelfReferenceLayout.StackLayoutElement.Children) { if (!(item is GridTreeExpanderItem)) { item.Visibility = ElementVisibility.Collapsed; } else { item.Visibility = ElementVisibility.Visible; } } } }
To reproduce: run the attached sample project and press the "stream export" button. Workaround: use the GridViewSpreadExport https://docs.telerik.com/devtools/winforms/gridview/exporting-data/spread-export Dim spreadExporter As GridViewSpreadExport = New GridViewSpreadExport(RadGridView1) Dim exportRenderer As New SpreadExportRenderer() Dim fileName As String = "..\..\Export" & DateTime.Now.ToLongTimeString().Replace(":", "_") + ".xlsx" spreadExporter.RunExport(fileName, exportRenderer)
Use attached to reproduce. - Check the filter box - Uncheck the header checkbox. - The cells are still visible and you cannot click on the data check boxes.
To reproduce: Public Class RadForm1 Public RadGridView1 As RadGridView Private Sub RadForm1_Load(sender As Object, e As EventArgs) Handles Me.Load CreateGrid() FormatGrid() SetDataSource() End Sub Private Sub CreateGrid() Try RadGridView1 = New RadGridView Me.Controls.Add(RadGridView1) Catch ex As Exception MessageBox.Show(Me, ex.Message) End Try End Sub Private Sub FormatGrid() Dim col As GridViewTextBoxColumn With RadGridView1 col = New GridViewTextBoxColumn With col .FieldName = "FieldID" 'NOTE: Comment out NullValue = "" to prevent the unhandled exception .NullValue = "" End With .Columns.Add(col) End With End Sub Private Sub SetDataSource() Dim table As DataTable = Nothing Dim row As DataRow = Nothing table = New DataTable("GridList") table.Columns.Add("FieldID", GetType(System.Guid)) row = table.NewRow row("FieldID") = Guid.Empty table.Rows.Add(row) RadGridView1.DataSource = table End Sub End Class Workaround: Comment this line NullValue = ""
Please refer to the attached sample project. The ResizeColumnsProportionally.gif illustrates the correct behavior of columns resizing. However, if you make a certain column with fixed size, the columns resizing is not proportional any more. The ColumnsWidthNOTAdjustedProportionally.gif demonstrates better the wrong behavior. Workaround: handle the SizeChanged event and adjust the columns' width property programmatically in order to obtain the desired widths.
Until the new functionality becomes available you can use the workaround solution in the attached project.
Excel does not support dates prior to 1/1/1900, however, we could export such dates as simple strings: https://support.office.com/en-us/article/excel-specifications-and-limits-1672b34d-7043-467e-8e27-269d656771c3 How to reproduce: public partial class Form1 : RadForm { public Form1() { InitializeComponent(); this.radGridView1.DataSource = this.GetData(); this.radGridView1.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill; } private object GetData() { DataTable dt = new DataTable(); dt.Columns.Add("Id", typeof(int)); dt.Columns.Add("Name", typeof(string)); dt.Columns.Add("Bool", typeof(bool)); dt.Columns.Add("Date", typeof(DateTime)); DateTime date = new DateTime(1850, 1, 1); for (int i = 0; i < 100; i++) { dt.Rows.Add(i, "Name " + i, i % 2 == 0, date.AddYears(i)); } return dt; } FieldInfo fi; private void radButton1_Click(object sender, EventArgs e) { //Old Export using the ExcelML format this.fi = typeof(Telerik.WinControls.UI.Export.ExcelML.CellElement).GetField("_dataElement", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic); ExportToExcelML exporter = new ExportToExcelML(this.radGridView1); string fileName = @"..\..\data.xls"; exporter.RunExport(fileName); //New export utilizing the SpreadProcessing libraries GridViewSpreadExport spreadExporter = new GridViewSpreadExport(this.radGridView1); SpreadExportRenderer exportRenderer = new SpreadExportRenderer(); spreadExporter.RunExport(@"..\..\data.xlsx", exportRenderer); } } Workaround: handle the CellFormatting event public partial class Form1 : RadForm { public Form1() { InitializeComponent(); this.radGridView1.DataSource = this.GetData(); this.radGridView1.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill; } private object GetData() { DataTable dt = new DataTable(); dt.Columns.Add("Id", typeof(int)); dt.Columns.Add("Name", typeof(string)); dt.Columns.Add("Bool", typeof(bool)); dt.Columns.Add("Date", typeof(DateTime)); DateTime date = new DateTime(1850, 1, 1); for (int i = 0; i < 100; i++) { dt.Rows.Add(i, "Name " + i, i % 2 == 0, date.AddYears(i)); } return dt; } FieldInfo fi; private void radButton1_Click(object sender, EventArgs e) { //Old Export using the ExcelML format this.fi = typeof(Telerik.WinControls.UI.Export.ExcelML.CellElement).GetField("_dataElement", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic); ExportToExcelML exporter = new ExportToExcelML(this.radGridView1); exporter.ExcelCellFormatting += Exporter_ExcelCellFormatting; string fileName = @"..\..\data.xls"; exporter.RunExport(fileName); //New export utilizing the SpreadProcessing libraries GridViewSpreadExport spreadExporter = new GridViewSpreadExport(this.radGridView1); spreadExporter.CellFormatting += SpreadExporter_CellFormatting; SpreadExportRenderer exportRenderer = new SpreadExportRenderer(); spreadExporter.RunExport(@"..\..\data.xlsx", exportRenderer); } private void SpreadExporter_CellFormatting(object sender, Telerik.WinControls.Export.CellFormattingEventArgs e) { if (e.GridRowIndex >= 1 && e.GridCellInfo.ColumnInfo is GridViewDateTimeColumn && ((DateTime)e.GridCellInfo.Value).Year < 1900) { Telerik.Windows.Documents.Spreadsheet.Model.CellSelection cell = e.CellSelection as Telerik.Windows.Documents.Spreadsheet.Model.CellSelection; cell.SetValue(e.GridCellInfo.Value.ToString()); } } private void Exporter_ExcelCellFormatting(object sender, Telerik.WinControls.UI.Export.ExcelML.ExcelCellFormattingEventArgs e) { if (e.GridRowIndex > -1 && e.GridCellInfo.ColumnInfo is GridViewDateTimeColumn && ((DateTime)e.GridCellInfo.Value).Year < 1900) { DataElement data = new DataElement(); data.DataItem = e.GridCellInfo.Value.ToString(); this.fi.SetValue(e.ExcelCellElement, data); } } }
Workaround: handle the GridViewPdfExport.CellFormatting event and apply the column`s format string Public Class Form1 Sub New() InitializeComponent() Me.RadGridView1.DataSource = Me.GetData() Me.RadGridView1.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill Dim decimalColumn = DirectCast(Me.RadGridView1.Columns("Money"), GridViewDecimalColumn) decimalColumn.DecimalPlaces = 0 decimalColumn.FormatString = "{0:C0}" Dim dateTimeColumn = DirectCast(Me.RadGridView1.Columns("Date"), GridViewDateTimeColumn) dateTimeColumn.FormatString = "{0:D}" End Sub Private Function GetData() As Object Dim dataTable As New DataTable() dataTable.Columns.Add("Id", GetType(Integer)) dataTable.Columns.Add("Name", GetType(String)) dataTable.Columns.Add("Money", GetType(Decimal)) dataTable.Columns.Add("Date", GetType(DateTime)) For i As Integer = 0 To 999 dataTable.Rows.Add(i, "Name " & i, i * 10, DateTime.Now.AddDays(i)) Next Return dataTable End Function Private Sub RadButton1_Click(sender As Object, e As EventArgs) Handles RadButton1.Click Dim pdfExporter = New GridViewPdfExport(Me.RadGridView1) AddHandler pdfExporter.CellFormatting, AddressOf pdfExporter_CellFormatting Dim renderer = New PdfExportRenderer() Dim fileName As String = "..\..\exported-grid.pdf" pdfExporter.RunExport(fileName, renderer) End Sub Private Sub pdfExporter_CellFormatting(sender As Object, e As PdfExportCellFormattingEventArgs) If e.RowIndex > -1 Then e.CellElement.Text = TryCast(RadDataConverter.Instance.Format(e.Row.Cells(e.ColumnIndex).Value, GetType(String), e.Column), String) End If End Sub End Class