Description: if you filter a text column with "Does not contains" operator, the produced FilterDescriptors.Expression is "ProductName NOT LIKE '%c%' OR ProductName IS NULL". However, if you try to programmatically add this expression to the RadGridView.FilterDescriptors.Expression property it doesn't filter the grid. Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load Me.ProductsTableAdapter.Fill(Me.NwindDataSet.Products) Me.RadGridView1.EnableFiltering = True End Sub Private Sub RadButton1_Click(sender As Object, e As EventArgs) Handles RadButton1.Click Me.RadGridView1.FilterDescriptors.Expression = "ProductName NOT LIKE '%c%' OR ProductName IS NULL" End Sub Workaround: don't set expression but add a FilterDescriptor: http://docs.telerik.com/devtools/winforms/gridview/filtering/setting-filters-programmatically-(simple-descriptors) Dim filter1 As New FilterDescriptor() filter1.[Operator] = FilterOperator.NotContains filter1.Value = "c" filter1.IsFilterEditor = True filter1.PropertyName = "ProductName" Me.RadGridView1.FilterDescriptors.Add(filter1)
How to reproduce: public partial class Form1 : Form { public Form1() { InitializeComponent(); GridViewDecimalColumn decimalColumn = new GridViewDecimalColumn(); decimalColumn.Name = "DecimalColumn"; decimalColumn.HeaderText = "DecimalColumn"; this.radGridView1.MasterTemplate.Columns.Add(decimalColumn); GridViewTextBoxColumn textBoxColumn = new GridViewTextBoxColumn(); textBoxColumn.Name = "TextBoxColumn"; textBoxColumn.HeaderText = "TextBoxColumn"; this.radGridView1.MasterTemplate.Columns.Add(textBoxColumn); GridViewDateTimeColumn dateTimeColumn = new GridViewDateTimeColumn(); dateTimeColumn.Name = "DateTimeColumn"; dateTimeColumn.HeaderText = "DateTimeColumn"; this.radGridView1.MasterTemplate.Columns.Add(dateTimeColumn); } } Workaround: this.radGridView1.MasterView.TableAddNewRow.MinHeight = 30;
Please refer to the attached sample project. Activate the editor for the "Notes" column of the first row, don't perform any changes and click another row. You will notice that the DataRow.RowState is Modified although no change is performed. If you perform the same actions with a MS DataGridView, the RowState is not Modified. Note: the GridViewRowInfo.IsModified property in the CellEndEdit is also set to true without modifying the cell's value. Workaround: handle the CellBeginEdit and CellEndEdit events and compare the values before and after the edit operation: object initialValue = null; private void radGridView1_CellBeginEdit(object sender, GridViewCellCancelEventArgs e) { initialValue = e.Row.Cells[e.ColumnIndex].Value; } private void radGridView1_CellEndEdit(object sender, GridViewCellEventArgs e) { if (initialValue != e.Value) { Console.WriteLine("modified"); } else { Console.WriteLine("NOT modified"); } }
Hello, we have a RadGridview with a number column and a activated filter for this Grid. If we want to filter data by the value "123" the input in the filter textBox is shown as "321.00" (right-to-left). This is no problem by columns with text values. And at the line for a new data row the input is correct, too.
To reproduce: private void radButton1_Click(object sender, EventArgs e) { radGridView1.Rows[0].Cells[0].Value = false; } private void Form1_Load(object sender, EventArgs e) { radGridView1.AllowSearchRow = true; radGridView1.TableElement.SearchHighlightColor = Color.Orange; radGridView1.AutoExpandGroups = true; DataTable dt = new DataTable(); dt.Columns.Add("test", typeof(bool)); dt.Rows.Add(true); dt.Rows.Add(true); dt.Rows.Add(true); dt.Rows.Add(true); dt.Rows.Add(true); dt.Rows.Add(true); dt.Rows.Add(true); dt.Rows.Add(true); dt.Rows.Add(true); dt.Rows.Add(true); dt.Rows.Add(true); dt.Rows.Add(true); dt.Rows.Add(true); dt.Rows.Add(true); dt.Rows.Add(true); dt.Rows.Add(true); dt.Rows.Add(true); dt.Rows.Add(true); dt.Rows.Add(true); dt.Rows.Add(true); dt.Rows.Add(true); dt.Rows.Add(true); dt.Rows.Add(true); dt.Rows.Add(true); dt.Rows.Add(true); radGridView1.DataSource = dt; ((Telerik.WinControls.UI.GridViewCheckBoxColumn) radGridView1.Columns[0]).EnableHeaderCheckBox = true; ((Telerik.WinControls.UI.GridViewCheckBoxColumn) radGridView1.Columns[0]).Width = radGridView1.Width - 50; radGridView1.TableElement.Update(Telerik.WinControls.UI.GridUINotifyAction.Reset); //force header checkbox to check radGridView1.TableElement.ScrollTo(15, 0); } Workaround: private void radButton1_Click(object sender, EventArgs e) { radGridView1.Rows[0].Cells[0].Value = false; radGridView1.TableElement.Update(Telerik.WinControls.UI.GridUINotifyAction.Reset); //force header checkbox to check }
To reproduce: DataTable dt = new DataTable(); dt.Columns.Add("Id", typeof(int)); dt.Columns.Add("Name", typeof(string)); dt.Columns.Add("IsActive", typeof(bool)); dt.Rows.Add(1, "Parent1", false); dt.Rows.Add(2, "Parent2", false); this.radGridView1.DataSource = dt; ((GridViewCheckBoxColumn)this.radGridView1.MasterTemplate.Columns["IsActive"]).EnableHeaderCheckBox = true; this.radGridView1.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill; DataTable childDataTable = new DataTable(); childDataTable.Columns.Add("Id", typeof(int)); childDataTable.Columns.Add("Title", typeof(string)); childDataTable.Columns.Add("ParentId", typeof(int)); childDataTable.Columns.Add("IsValid", typeof(bool)); childDataTable.Rows.Add(1, "Child 1", 1, false); childDataTable.Rows.Add(2, "Child 1", 1, false); childDataTable.Rows.Add(3, "Child 2", 2, false); childDataTable.Rows.Add(4, "Child 2", 2, false); GridViewTemplate template = new GridViewTemplate(); template.DataSource = childDataTable; ((GridViewCheckBoxColumn)template.Columns["IsValid"]).EnableHeaderCheckBox = true; radGridView1.MasterTemplate.Templates.Add(template); template.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill; GridViewRelation relation = new GridViewRelation(radGridView1.MasterTemplate); relation.ChildTemplate = template; relation.RelationName = "MasterDeatial"; relation.ParentColumnNames.Add("Id"); relation.ChildColumnNames.Add("ParentId"); radGridView1.Relations.Add(relation);
To reproduce: populate the grid with data and use the following code snippet: Me.RadGridView1.EnableAlternatingRowColor = True Me.RadGridView1.TableElement.AlternatingRowColor = Color.LightGray Me.RadGridView1.MultiSelect = True Me.RadGridView1.SelectionMode = Telerik.WinControls.UI.GridViewSelectionMode.CellSelect Select multiple cells from different rows. You will notice that alternating color is not applied to the rows for which you have a selected cell. The attached gif file illustrates the behavior. Workaround: Sub New() InitializeComponent() Me.RadGridView1.MultiSelect = True Me.RadGridView1.SelectionMode = Telerik.WinControls.UI.GridViewSelectionMode.CellSelect End Sub Private Sub RadGridView1_CellFormatting(sender As Object, e As Telerik.WinControls.UI.CellFormattingEventArgs) _ Handles RadGridView1.CellFormatting e.CellElement.DrawFill = True e.CellElement.GradientStyle = Telerik.WinControls.GradientStyles.Solid If e.CellElement.IsSelected Then e.CellElement.ResetValue(LightVisualElement.BackColorProperty, ValueResetFlags.Local) ElseIf e.CellElement.RowInfo.Index Mod 2 = 0 Then e.CellElement.BackColor = Color.White Else e.CellElement.BackColor = Color.LightGray End If End Sub
To reproduce: use the following code snippet and have a look at the attached gif file. Steps: 1.Populate RadGridView with data and enable Excel-like filtering. 2.Click on a column filter icon and type in the Search textbox so more than two results appear. Then, click OK 2.The grid returns correct result. 3. Click on the previous column filter icon and navigate to Available Filters -> Contains 4. Evaluate the initial pop up dialog. You will notice that the 3rd filter descriptor is not displayed in the form. 5. Then, click OK 6. A message that says: "The composite filter descriptor is not valid". 7. Change the latter condition to "No filter" and click OK 8. The grid returns correct result. CompositeFilterForm should be improved on a way to display all applied filters,not only two of them. public Form1() { InitializeComponent(); DataTable dt = new DataTable(); dt.Columns.Add("Group", typeof(string)); dt.Columns.Add("Description", typeof(string)); for (int i = 0; i < 20; i++) { dt.Rows.Add(GenerateWord(3), "Description"); } this.radGridView1.DataSource = dt; this.radGridView1.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill; this.radGridView1.EnableFiltering = true; this.radGridView1.ShowHeaderCellButtons = true; this.radGridView1.ShowFilteringRow = false; this.radGridView1.CreateCompositeFilterDialog += radGridView1_CreateCompositeFilterDialog; } string word = null; int cons; int vow; //counter int i = 0; bool isword = false; Random rand = new Random(); //set a new string array of consonants string[] consonant = new string[] { "b", "c", "d", "f", "g", "h", "j", "k", "l", "m", "n", "p", "q", "r", "s", "t", "v", "w", "x", "y", "z" }; //set a new string array of vowels string[] vowel = new string[] { "a", "e", "i", "o", "u" }; string GenerateWord(int length) { if (length < 1) // do not allow words of zero length throw new ArgumentException("Length must be greater than 0"); string word = string.Empty; if (rand.Next() % 2 == 0) // randomly choose a vowel or consonant to start the word word += consonant[rand.Next(0, 20)]; else word += vowel[rand.Next(0, 4)]; for (int i = 1; i < length; i += 2) // the counter starts at 1 to account for the initial letter { // and increments by two since we append two characters per pass string c = consonant[rand.Next(0, 20)]; string v = vowel[rand.Next(0, 4)]; if (c == "q") // append qu if the random consonant is a q word += "qu"; else // otherwise just append a random consant and vowel word += c + v; } // the word may be short a letter because of the way the for loop above is constructed if (word.Length < length) // we'll just append a random consonant if that's the case word += consonant[rand.Next(0, 20)]; return word; } Workaround: By using the CreateCompositeFilterDialog event you can replace the default CompositeFilterForm with your custom one where you can load all available filter descriptors.
The GridViewCheckBoxColumn.EditMode property controls when the value of the editor will be submitted to the cell. By default, the value is OnValidate and the value will be submitted only when the current cell changes, the grid looses focus or the active editor is closed by pressing Enter. If you set the EditMode property to OnValueChange it will submit the value immediately after the editor value changes. Please refer to the attached gif files illustrating the difference between the two modes. To reproduce: if you set the GridViewCheckBoxColumn.EnableHeaderCheckBox property to true, the cell value is always submitted immediately after toggle/untoggle the checkbox without considering that EditMode.OnValidate is used.
virtual filtering operation - detached filter GUI to support filtering in external datasource or possibility to replace the data in RadGridView control when new filter is applied.
To reproduce: Sub New() InitializeComponent() Dim dt As New DataTable dt.Columns.Add("Id", GetType(Integer)) dt.Columns.Add("Name", GetType(String)) dt.Columns.Add("Description", GetType(String)) For index = 1 To 5 dt.Rows.Add(index, "Item" & index, "Description" & index) Next Me.RadGridView1.DataSource = dt Me.RadGridView1.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill AddHandler Me.RadGridView1.UserAddingRow, AddressOf UserAddingRow End Sub Private Sub UserAddingRow(sender As Object, e As Telerik.WinControls.UI.GridViewRowCancelEventArgs) Me.RadGridView1.MasterView.TableAddNewRow.ErrorText = "" If String.IsNullOrEmpty(e.Rows(0).Cells(0).Value) Then e.Cancel = True Me.RadGridView1.MasterView.TableAddNewRow.ErrorText = "Empty value is not allowed!" End If End Sub 1. Click the new row and enter a value in the last cell. 2. Click outside the new row, e.g. click on a data row. The UserAddingRow event is canceled and the new row remains current. 3. Click a data row again without any modification on the new row. The new row is not current anymore. 4. However, you perform step 1and 2 but instead of clicking a data row, the user clicks a header cell, the new row is not current from the first time. It is necessary to forbid the user to exit the new row until the validation passes or the new row is canceled by pressing Enter. Workaround: use the CellValidating/RowValidating event for validating.
To reproduce: public Form1() { InitializeComponent(); DataTable dt = new DataTable(); dt.Columns.Add("Id"); dt.Columns.Add("Name"); for (int i = 0; i < 1; i++) { dt.Rows.Add(i, "Item"); } this.radGridView1.DataSource = dt; this.radGridView1.SelectionMode = GridViewSelectionMode.FullRowSelect; this.radGridView1.ClipboardCopyMode = Telerik.WinControls.UI.GridViewClipboardCopyMode.EnableAlwaysIncludeHeaderText; this.radGridView1.MultiSelect = true; } private void button1_Click(object sender, EventArgs e) { this.radGridView1.SelectAll(); this.radGridView1.Copy(); } If you click the button, you will notice that only one cell is copied. However, if you add 2 and more rows, the whole grid content will be copied to the clipboard. Workaround: use the BeginRowCopy/EndRowCopy methods. private void button1_Click(object sender, EventArgs e) { this.radGridView1.SelectAll(); this.radGridView1.MasterTemplate.BeginRowCopy(); this.radGridView1.Copy(); this.radGridView1.MasterTemplate.EndRowCopy(); }
The event should be used to cancel copying for a single cell or override the value to be copied to the Clipboard.
To reproduce: public Form1() { InitializeComponent(); for (int i = 0; i < 10; i++) { this.radGridView1.Columns.Add("column " + i); } int charsCount = 5; for (int i = 0; i < 20; i++) { this.radGridView1.Rows.Add(new string('0', charsCount), new string('1', charsCount), new string('2', charsCount), new string('3', charsCount), new string('4', charsCount), new string('5', charsCount), new string('6', charsCount), new string('7', charsCount), new string('8', charsCount), new string('9', charsCount)); } HtmlViewDefinition view = new HtmlViewDefinition(); view.RowTemplate.Rows.Add(new RowDefinition()); view.RowTemplate.Rows.Add(new RowDefinition()); view.RowTemplate.Rows.Add(new RowDefinition()); view.RowTemplate.Rows[0].Cells.Add(new CellDefinition("Column 0", 0, 1, 1)); view.RowTemplate.Rows[0].Cells.Add(new CellDefinition("Column 1", 0, 1, 3)); view.RowTemplate.Rows[0].Cells.Add(new CellDefinition("Column 2", 0, 1, 1)); view.RowTemplate.Rows[0].Cells.Add(new CellDefinition("Column 3", 0, 1, 1)); view.RowTemplate.Rows[0].Cells.Add(new CellDefinition("Column 7", 0, 1, 1)); view.RowTemplate.Rows[1].Cells.Add(new CellDefinition("Column 4", 0, 1, 2)); view.RowTemplate.Rows[1].Cells.Add(new CellDefinition("Column 5", 0, 2, 1)); view.RowTemplate.Rows[1].Cells.Add(new CellDefinition("Column 8", 0, 1, 1)); view.RowTemplate.Rows[2].Cells.Add(new CellDefinition("Column 6", 0, 2, 1)); view.RowTemplate.Rows[2].Cells.Add(new CellDefinition("Column 9", 0, 1, 1)); this.radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill; this.radGridView1.ViewDefinition = view; } Workaround: private void radGridView1_SizeChanged(object sender, EventArgs e) { this.radGridView1.MasterTemplate.Refresh(); }
To reproduce: DataTable dt = new DataTable(); public Form1() { InitializeComponent(); dt.Columns.Add("Id"); dt.Columns.Add("Name"); dt.Columns.Add("Type"); for (int i = 0; i < 30; i++) { dt.Rows.Add(i, "Item" + i, "Type" + i % 2); } this.radGridView1.DataSource = dt; this.radGridView1.AutoExpandGroups = true; GroupDescriptor descriptor = new GroupDescriptor(); descriptor.GroupNames.Add("Type", ListSortDirection.Ascending); this.radGridView1.GroupDescriptors.Add(descriptor); } private void button1_Click(object sender, EventArgs e) { dt.Rows.Add(30, "Item30", "Type3"); } Workaround: set the AutoExpandGroups property to false and manually expand the groups when a new row is added.
When the EnableHeaderCheckBox property is set to true, whenever the checkbox is clicked in the new row, a new row is actually added to the grid before any other modifications are made. This can be replicated in the attached sample project. Run it and click the checkbox in the new row several times. Multiple rows are added. Workaround: cancel the RadGridView.UserAddingRow until all the required fields are filled.
To reproduce - Set the AutoSize and AutoSizeRows properties to true. - Start editing a cell. - Exception occurs. Workaround: class MyGrid : RadGridView { protected override void OnResize(EventArgs e) { //base.OnResize(e); } }
To reproduce: - Add a grid to a form and set the EnableHotTracking property to false in the properties window. - When the application is started the property is reset. Workaround: Set the property at runtime.
To reproduce: add a RadGridView and a RadButton on the form. Use the following code snippet: public RadForm1() { InitializeComponent(); this.radGridView1.Columns.Add("Col1"); this.radGridView1.Columns.Add("Col2"); for (int i = 0; i < 5; i++) { this.radGridView1.Rows.Add(i, "Item" + i); } this.radGridView1.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill; this.radGridView1.RowValidating += radGridView1_RowValidating; this.radGridView1.UserAddingRow += radGridView1_UserAddingRow; } private void radGridView1_UserAddingRow(object sender, Telerik.WinControls.UI.GridViewRowCancelEventArgs e) { e.Cancel = true; } private void radGridView1_RowValidating(object sender, Telerik.WinControls.UI.RowValidatingEventArgs e) { if (e.Row.IsModified && e.Row is GridViewDataRowInfo) { e.Cancel = true; } } private void radButton1_Click(object sender, EventArgs e) { RadMessageBox.Show("Clicked"); } 1. Select a data cell and activate the editor. Enter some new value and click the button. The Click event is fired. 2. Select the new row and activate the editor. Enter some value and click the button. The Click event is NOT fired. Workaround: use the CellValidating event instead.