To reproduce:
1. Add text box and check box column to the grid. Add a filter descriptor to the text box column
2. Bind it to a DataTable with some data
3. Clear the columns
4. Add the columns once again => the exception will be thrown
Workaround.
1. Create the following cell element:
class MyHeaderCell : GridCheckBoxHeaderCellElement
{
public MyHeaderCell(GridViewColumn column, GridRowElement row)
: base(column, row)
{
}
protected override bool SetCheckBoxState()
{
if (this.ColumnIndex == -1)
{
return false;
}
return base.SetCheckBoxState();
}
}
2. Subscribe to the grid's CreateCell event
3. Put the modified cell in action:
void radGridView_CreateCell(object sender, GridViewCreateCellEventArgs e)
{
if (e.CellType == typeof(GridCheckBoxHeaderCellElement))
{
e.CellType = typeof(MyHeaderCell);
}
}
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);
}
}
Add RadPageView with couple pages Add a grid to one of the pages Start editing a cell Click another page item (tab) to change the selected page => even though no validation is performed, the selected page is not changed unless a second click is performed. The first click just closes the editor and the second one changes the selected page.
Currently when RadGridView contains multiple header rows and its layout is being saved, after loading it the grid shows "No data to display" although it is binded to a data source. Add a functionality to support saving the layout when RadGridView contains multiple header rows
Save\Load functionality of the control should work with ColumnGroupsViewDefinition.
Currently it is not possible to change the table header row height when using column groups view definition.
Excluding certain properties when layout is being saved
1. By default I cannot paste data on the radgrid if I don't have any rows created.For e.g in a grid with no rows I cannot paste data on the radgrid.Is there any setting to chane this behavior? 2. When I copy data from excel and paste in the grid the column order has to be the same as that in the excel.For e.g in the excel the columns are A,B,C and in the grid the order is C,B,A..Then 'paste' copies A' data to C and C's data on excel to column A on the grid. Is it possible to trap the pasting programmatically to paste A's data in excel to A's column of the grid.ie. one to one. irrespective of the column order mismatch between the excel and the grid? Also I should be able to paste data to an empty grid by identifying how many rows needs to be created.
i would like to customize the grid like below attached screen shot,is it possible using telerik win forms (rad grid view), if possible can you please send me sample code for that, if not possible can you suggest me alternate solution for this requirement.
Currently if a user hits the decimal separator key the grid opens a cell for edit and selects its content. If the user does not notice this he may enter 1 instead of 0.1
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.
To reproduce: use the following code snippet:
DataTable dt = new DataTable();
dt.Columns.Add("Id", typeof(int));
dt.Columns.Add("Name", typeof(string));
dt.Columns.Add("IsActive", typeof(bool));
for (int i = 0; i < 20; i++)
{
if (i % 5 == 0)
{
dt.Rows.Add(i, "Item" + i, true);
}
{
dt.Rows.Add(i, "Item" + i, DBNull.Value);
}
}
this.radGridView1.DataSource = dt;
this.radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
this.radGridView1.EnableFiltering = true;
Try to filter by "Name" column via entering "4". As a result an InvalidCastException occurs.
Workaround: initialize default value for the cells belonging to GridViewCheckBoxColumn with false if it is DBNull:
foreach (GridViewRowInfo r in this.radGridView1.Rows)
{
if (r.Cells["IsActive"].Value == DBNull.Value)
{
r.Cells["IsActive"].Value = false;
}
}
To reproduce: use the code from our demo application for Custom Filtering. Instead of Customers table, bind the grid to Orders or another table with 1000+ rows.
Resolution: You can surround the row operation in Begin/EndUpdate(false) and remove the InvalidateRow method. The Custom Filtering example in our demo Application is updated for better performance or you can use the following code snippet:
For example:
private void radGridView1_CustomFiltering(object sender, Telerik.WinControls.UI.GridViewCustomFilteringEventArgs e)
{
if (string.IsNullOrEmpty(this.radTextBox1.Text))
{
this.radGridView1.BeginUpdate();
e.Visible = true;
for (int i = 0; i < this.radGridView1.ColumnCount; i++)
{
e.Row.Cells[i].Style.Reset();
}
//e.Row.InvalidateRow();
this.radGridView1.EndUpdate(false);
return;
}
this.radGridView1.BeginUpdate();
e.Visible = false;
for (int i = 0; i < this.radGridView1.ColumnCount; i++)
{
string text = e.Row.Cells[i].Value.ToString();
if (text.IndexOf(this.radTextBox1.Text, 0, StringComparison.InvariantCultureIgnoreCase) >= 0)
{
e.Visible = true;
e.Row.Cells[i].Style.CustomizeFill = true;
e.Row.Cells[i].Style.DrawFill = true;
e.Row.Cells[i].Style.BackColor = Color.FromArgb(201, 252, 254);
}
else
{
e.Row.Cells[i].Style.Reset();
}
}
//e.Row.InvalidateRow();
this.radGridView1.EndUpdate(false);
}
To reproduce:
Download the attached project, run it and try to filter the bottom grid. You will see the exception
Workaround:
Use the following custom RadGridView:
public class MyGrid : RadGridView
{
protected override RadGridViewElement CreateGridViewElement()
{
return new MyGridElement();
}
}
public class MyGridElement : RadGridViewElement
{
protected override MasterGridViewTemplate CreateTemplate()
{
return new MyMasterTemplate();
}
protected override Type ThemeEffectiveType
{
get
{
return typeof(RadGridViewElement);
}
}
}
public class MyMasterTemplate : MasterGridViewTemplate
{
private MyEventDispatcher dispatcher = new MyEventDispatcher();
public override EventDispatcher EventDispatcher
{
get
{
return this.dispatcher;
}
}
}
public class MyEventDispatcher : EventDispatcher
{
public override void RaiseEvent<T>(object eventKey, object sender, T args)
{
GridViewCellEventArgs cellArgs = args as GridViewCellEventArgs;
if (cellArgs != null && cellArgs.Column == null && cellArgs.Row == null)
{
typeof(GridViewCellEventArgsBase)
.GetField("column", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic)
.SetValue(cellArgs, new GridViewTextBoxColumn());
typeof(GridViewCellEventArgsBase)
.GetField("row", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic)
.SetValue(cellArgs, new GridViewDataRowInfo(null));
}
base.RaiseEvent<T>(eventKey, sender, args);
}
}
To reproduce: use the following code snippet:
Steps to repeat:
1. A Self-Referencing Hierarchical Grid is displayed, grouped by the "Title" column.
3. Expand the first group.
4. Check the first row check box. As a result the editor is activated and its value is changed.
5. Click on the "+" sign in 1st row of data to expand and see child rows or just close the editor. You will notice that the group is unexpectedly collapsed.
Workaround:
private void radGridView1_ValueChanged(object sender, EventArgs e)
{
if (this.radGridView1.ActiveEditor is RadCheckBoxEditor)
{
if (this.radGridView1.CurrentRow.Group != null && this.radGridView1.CurrentRow.Group.IsExpanded)
{
this.radGridView1.EndEdit();
this.radGridView1.CurrentRow.Group.Expand();
}
}
}
To reproduce:
public Form1()
{
InitializeComponent();
BindingSource bs1 = new BindingSource();
BindingSource bs2 = new BindingSource();
DataTable dt1 = new DataTable();
dt1.Columns.Add("MortgageId", typeof(string));
dt1.Columns.Add("MortgageNo", typeof(string));
for (int i = 0; i < 50; i++)
{
dt1.Rows.Add(i, Guid.NewGuid().ToString().Substring(0, 5));
}
bs1.DataSource = dt1;
DataTable dt2 = new DataTable();
dt2.Columns.Add("PaymentCode", typeof(string));
dt2.Columns.Add("Description", typeof(string));
for (int i = 0; i < 50; i++)
{
dt2.Rows.Add(Guid.NewGuid().ToString().Substring(0, 5), Guid.NewGuid().ToString().Substring(0, 5));
}
bs2.DataSource = dt2;
GridViewMultiComboBoxColumn col1 = new GridViewMultiComboBoxColumn("MortgageId");
col1.DataSource = bs1;
col1.FieldName = "MortgageId";
col1.DisplayMember = "MortgageId";
col1.ValueMember = "MortgageId";
col1.Width = 70;
this.radGridView1.Columns.Add(col1);
col1 = new GridViewMultiComboBoxColumn("PaymentCode");
col1.DataSource = bs2;
col1.DisplayMember = "PaymentCode";
col1.ValueMember = "PaymentCode";
col1.FieldName = "PaymentCode";
col1.Width = 70;
this.radGridView1.Columns.Add(col1);
this.radGridView1.CellEditorInitialized += radGridView1_CellEditorInitialized;
}
private void radGridView1_CellEditorInitialized(object sender, Telerik.WinControls.UI.GridViewCellEventArgs e)
{
if (e.Column.Name == "MortgageId")
{
RadMultiColumnComboBoxElement editor = e.ActiveEditor as RadMultiColumnComboBoxElement;
if (editor != null)
{
editor.EditorControl.FilterDescriptors.Clear();
editor.EditorControl.Columns.Clear();
editor.EditorControl.MasterTemplate.AutoGenerateColumns = false;
editor.EditorControl.Columns.Add(new GridViewTextBoxColumn("MortgageId"));
editor.EditorControl.Columns.Add(new GridViewTextBoxColumn("MortgageNo"));
editor.DropDownWidth = 200;
}
return;
}
if (e.Column.Name == "PaymentCode")
{
RadMultiColumnComboBoxElement editor = e.ActiveEditor as RadMultiColumnComboBoxElement;
if (editor != null)
{
editor.EditorControl.FilterDescriptors.Clear();
editor.EditorControl.Columns.Clear();
editor.EditorControl.MasterTemplate.AutoGenerateColumns = false;
editor.EditorControl.Columns.Add(new GridViewTextBoxColumn("PaymentCode"));
editor.EditorControl.Columns.Add(new GridViewTextBoxColumn("Description"));
editor.DropDownWidth = 200;
}
return;
}
}
Workaround: do not set the RadMultiColumnComboBoxElement.EditorControl.MasterTemplate.AutoGenerateColumns property to false in the CellEditorInitialized event .
Workaround:
RadDragDropService dragDropService;
int scrollValue = 0;
public Form1()
{
InitializeComponent();
dragDropService = this.leftGrid.GridViewElement.GetService<RadDragDropService>();
dragDropService.Started += dragDropService_Started;
leftGrid.TableElement.VScrollBar.ValueChanged += VScrollBar_ValueChanged;
}
private void dragDropService_Started(object sender, EventArgs e)
{
scrollValue = this.leftGrid.TableElement.VScrollBar.Value;
}
private void VScrollBar_ValueChanged(object sender, EventArgs e)
{
if (dragDropService != null && dragDropService.State == RadServiceState.Working)
{
this.leftGrid.TableElement.VScrollBar.Value = scrollValue;
}
}
Resolution:
Added AllowAutoScrollColumnsWhileDragging and AllowAutoScrollRowsWhileDragging properties of RadGridViewDragDropService:
RadGridViewDragDropService svc = this.GridViewElement.GetService<RadGridViewDragDropService>();
svc.AllowAutoScrollColumnsWhileDragging = false;
svc.AllowAutoScrollRowsWhileDragging = false;
svc.Start(row);
RadGridView issue: Can not change the Operator or Value of FilterDescriptor in FilterChanging event handler
It is related to GridViewCalculatorColumn, GridViewBrowseColumn. Workaround: use a custom row behavior and override the ProcessAlphaNumericKey method to initialize the editor with the respective value. http://www.telerik.com/help/winforms/gridview-rows-row-behaviors.html