Stack Overflow Exception in the CellValueNeeded Event after sorting when RowIndex, ColumnIndex arguments is used
Selecting datasource throws exception, then crashes VS
To reproduce:
1. Add a RadTreeView and a RadGridView
2. Use the following code snippet.
3. Select a node from the RadtreeView.
4. Activate the editor for the new row in RadGridView.
5. While the grid editor is active, select a new node in the tree.
public Form1()
{
InitializeComponent();
this.radGridView1.MasterTemplate.AddNewBoundRowBeforeEdit = true;
}
public class ClassA
{
public int Id { get; set; }
public string Name { get; set; }
public string Grade { get; set; }
public ClassA()
{
}
public ClassA(int id, string name, string grade)
{
this.Id = id;
this.Name = name;
this.Grade = grade;
}
}
public class ClassB
{
public int NewID { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public ClassB()
{
}
public ClassB(int id, string firstName, string lastName)
{
this.NewID = id;
this.FirstName = firstName;
this.LastName = lastName;
}
}
private void radTreeView1_SelectedNodeChanged(object sender, Telerik.WinControls.UI.RadTreeViewEventArgs e)
{
if (radGridView1.DataSource is BindingList<ClassA>)
{
this.radGridView1.Columns.Clear();
this.radGridView1.DataSource = null;
BindingList<ClassB> list = new BindingList<ClassB>() { new ClassB(1, "John", "Wick") };
this.radGridView1.DataSource = list;
}
else
{
this.radGridView1.DataSource = null;
BindingList<ClassA> list = new BindingList<ClassA>() { new ClassA(1,"John", "A+") };
this.radGridView1.Columns.Clear();
this.radGridView1.DataSource = list;
}
}
Workaround: this.radGridView1.MasterTemplate.AddNewBoundRowBeforeEdit = false;
ADD. RadGridView - one should be able to show the header row on each page exported in PDF
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);
}
}
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;
}
}
http://www.telerik.com/forums/gridview---adding-a-third-hierarchy-or-level#HdPZFtCJR0q1OCXxVR5wjg
Dim ID As New GridViewDecimalColumn()
ID.Name = "ID"
ID.HeaderText = "Id"
RadGridView1.MasterTemplate.Columns.Add(ID)
Dim Name As New GridViewTextBoxColumn()
Name.Name = "Name"
Name.HeaderText = "Name"
Name.Width = 100
RadGridView1.MasterTemplate.Columns.Add(Name)
Dim Under_Appeal As New GridViewCheckBoxColumn()
Under_Appeal.DataType = GetType(Boolean)
Under_Appeal.Name = "Under_Appeal"
Under_Appeal.HeaderText = "Under Appeal"
RadGridView1.MasterTemplate.Columns.Add(Under_Appeal)
Dim Terminated As New GridViewCheckBoxColumn()
Terminated.DataType = GetType(Boolean)
Terminated.Name = "Terminated"
Terminated.HeaderText = "Terminated"
RadGridView1.MasterTemplate.Columns.Add(Terminated)
Dim Hash As New GridViewDecimalColumn()
Hash.Name = "Hash"
Hash.HeaderText = "#"
RadGridView1.MasterTemplate.Columns.Add(Hash)
RadGridView1.Rows.Add(1, "John", True, True)
RadGridView1.Rows.Add(2, "Mary", True, False)
RadGridView1.Rows.Add(3, "Peter", False, True)
Dim template As New GridViewTemplate
template.Columns.Add(New GridViewDecimalColumn("ParentID"))
template.Columns.Add(New GridViewTextBoxColumn("TEXT"))
template.Columns.Add(New GridViewDecimalColumn("PRICE"))
RadGridView1.MasterTemplate.Templates.Add(template)
Dim relation As New GridViewRelation(RadGridView1.MasterTemplate)
relation.ChildTemplate = template
relation.RelationName = "PersonProduct"
relation.ParentColumnNames.Add("ID")
relation.ChildColumnNames.Add("ParentID")
RadGridView1.Relations.Add(relation)
template.Rows.Add(1, "sugar", 2.0)
template.Rows.Add(1, "cake", 12.0)
template.Rows.Add(1, "butter", 3.0)
template.Rows.Add(2, "cake", 12.0)
Dim template2 As New GridViewTemplate
template2.Columns.Add(New GridViewDecimalColumn("ParentID2"))
template2.Columns.Add(New GridViewTextBoxColumn("TYPE"))
template2.Columns.Add(New GridViewDecimalColumn("QTY"))
RadGridView1.MasterTemplate.Templates(0).Templates.Add(template2)
Dim relation2 As New GridViewRelation(RadGridView1.MasterTemplate.Templates(0))
relation2.ChildTemplate = template2
relation2.RelationName = "PersonProduct2"
relation2.ParentColumnNames.Add("ParentID")
relation2.ChildColumnNames.Add("ParentID2")
RadGridView1.Relations.Add(relation2)
template2.Rows.Add(1, "brown", 1)
template2.Rows.Add(1, "whiter", 3)
template2.Rows.Add(2, "banana", 2)
I am getting errors at runtime when I try to see the 3rd level in the hyerarchy.
FIX. RadGridView - seting the HeaderImage of a column in the PropertyBuilder results in Object Reference message
To reproduce, use this code:
AddGrid();
List<DropDownObject> lstDrp = new List<DropDownObject>();
DropDownObject drpObj = new DropDownObject();
drpObj.DropdownValue = "100";
drpObj.DropdownValueID = 1;
DropDownObject drpObj2 = new DropDownObject();
drpObj2.DropdownValue = "100";
drpObj2.DropdownValueID = 2;
DropDownObject drpObj1 = new DropDownObject();
drpObj1.DropdownValue = "101";
drpObj1.DropdownValueID = 1;
lstDrp.Add(drpObj);
lstDrp.Add(drpObj2);
lstDrp.Add(drpObj1);
DataTable dtMain = new DataTable();
DataColumn dcDropCol = new DataColumn();
dcDropCol.ColumnName = "DropDown Col";
dcDropCol.DataType = typeof(System.Int32);
dtMain.Columns.Add(dcDropCol);
DataRow dr = dtMain.NewRow();
dr["DropDown Col"] = 100;
dtMain.Rows.Add(dr);
var uniqueDropdownValues = lstDrp.GroupBy(s => s.DropdownValue).Select(s => s.First());
GridViewComboBoxColumn drpCol = new GridViewComboBoxColumn();
radGridView1.Columns.Add(drpCol); //first add the column
//drpCol.DataType = typeof(int); //then change its data type to change the filtering type from string to int
drpCol.Name = "DropDown Col";
drpCol.HeaderText = "Dropdown Col";
drpCol.FieldName = "Dropdown Col";
drpCol.DataSource = uniqueDropdownValues;
drpCol.ValueMember = "DropdownValue";
drpCol.DisplayMember = "DropdownValue";
drpCol.Width = 200;
drpCol.DropDownStyle = Telerik.WinControls.RadDropDownStyle.DropDown;
drpCol.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
drpCol.AllowFiltering = true;
radGridView1.EnableFiltering = true;
radGridView1.ShowHeaderCellButtons = true;
radGridView1.DataSource = dtMain;
radGridView1.AllowAddNewRow = true;
Save and load layout to work in all view definitions.
ADD. RadGridView should support filtering operations when custom TypeConverters are used.
To reproduce:
this.radGridView1.DataSource = this.ordersBindingSource;
GridViewDateTimeColumn col = this.radGridView1.Columns["OrderDate"] as GridViewDateTimeColumn;
col.ExcelExportType = DisplayFormatType.GeneralDate;
col.ExcelExportFormatString = "dd-MMM-yy";
private void radButton1_Click(object sender, EventArgs e)
{
SpreadExport spreadExporter = new SpreadExport(radGridView1);
spreadExporter.RunExport(@"..\..\..\exportedFileQ12015.xlsx");
Process.Start(@"..\..\..\exportedFileQ12015.xlsx");
}
Workaround:
private void radButton1_Click(object sender, EventArgs e)
{
SpreadExport spreadExporter = new SpreadExport(radGridView1);
spreadExporter.CellFormatting += spreadExporter_CellFormatting;
spreadExporter.RunExport(@"..\..\..\exportedFileQ12015.xlsx");
Process.Start(@"..\..\..\exportedFileQ12015.xlsx");
}
private void spreadExporter_CellFormatting(object sender, Telerik.WinControls.UI.Export.SpreadExport.CellFormattingEventArgs e)
{
if (e.GridColumnIndex == 3 && e.GridCellInfo.Value is DateTime)
{
CellValueFormat cvf = new CellValueFormat("dd-MMM-yy");
e.CellSelection.SetFormat(cvf);
}
}
To reproduce : - Set conditional formatting for all grid cells. - Iterate all grid cells and set their value. Workaround: Use Begin/End update block.
Workaround: use the API of RadGridView to delete the row
Currently none of the exporters can be canceled.
Presently it is not possible to persist customer created formatting objects in RadGridView.
Workaround: to avoid this behavior iterate the Rows collection of the master template and invoke their HasChildRows() method. which will sync up their parent
RadGridView should be able to create new rows using objects with properties matching the FieldNames of the control's columns.