Hello,
In our Environment it's not possible to assign a GroupComparer to another GridView template then MasterTemplate. The GroupComparer property is always null after assignment.
It's possible to assign our custom comparer to the MasterTemplate and it will be triggered, but not in another template then MasterTemplate.
Best regards.
Tassilo Koller | Dipl. Informatiker (FH) | IT-Softwareentwicklung
[T] +49 (0)8233 381 383
[E] Tassilo.Koller@forum-media.com | [W] www.forum-verlag.com
FORUM MEDIA GROUP GMBH| Mandichostraße 18 | 86504 Merching | [T] +49 (0)8233 381-0 | [F] + 49 (0)8233 381-222 | [W] www.forum-media.com| Sitz der Gesellschaft: Merching | Register: AG Augsburg HRB 11537 | Geschäftsführer: Magdalena Balanicka, Norbert Bietsch, Roland Hradek, Mihaela Mravlje | Beirat: Ronald Herkert (Vorsitzender)
Elektronische Rechnungen bitte an folgende Adresse senden: invoice@forum-media.com
Steps to reproduce:
This happens after calling RunExport.
I attached a gif and a sample project.
June 19, 2019
I have implemented this and it is exactly what I want and need, Thank you!
However I thought I might point out that when you tab out it doesn't implement the search, only when you press enter.
And when you press the X to clear the search it clears the text box but not the search. the count of found and the highlighted finds remain
In my gridview need support of different heights of rows. I solved it with the autosize property.
But now I have a side action that the header row and filter row also react to the autosize property.
Attached you can see this behaviour...
Here my code:
Grid.MasterView.TableFilteringRow.MinHeight = 40
Grid.AutoSizeRows = True
Is there a chance to separate data rows from filter and header row?
Regards,
Dimitri
To reproduce:
- Set the AutoSize to true
- Add GroupDescriptor
- An InvalidOperationException is thrown
To reproduce:
Sub New()
InitializeComponent()
Dim dt1 As New DataTable
dt1.Columns.Add("Id", GetType(Integer))
dt1.Columns.Add("Name", GetType(String))
For index = 1 To 20
dt1.Rows.Add(index, "Parent" & index)
Next
Me.RadGridView1.MasterTemplate.DataSource = dt1
Me.RadGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill
Dim dt2 As New DataTable
dt2.Columns.Add("Id", GetType(Integer))
dt2.Columns.Add("Name", GetType(String))
dt2.Columns.Add("ParentId", GetType(Integer))
Dim dt3 As New DataTable
dt3.Columns.Add("Id", GetType(Integer))
dt3.Columns.Add("Name", GetType(String))
dt3.Columns.Add("ParentId", GetType(Integer))
For index = 1 To 20
If index Mod 2 = 0 Then
dt2.Rows.Add(index, "Child1." & index, index)
If index Mod 4 = 0 Then
dt3.Rows.Add(index, "Child2." & index, index)
End If
ElseIf index Mod 3 = 0 Then
dt3.Rows.Add(index, "Child2." & index, index)
Else
dt3.Rows.Add(index, "Child2." & index, index)
End If
Next
Dim template As New GridViewTemplate()
template.DataSource = dt2
template.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill
RadGridView1.MasterTemplate.Templates.Add(template)
Dim relation As New GridViewRelation(RadGridView1.MasterTemplate)
relation.ChildTemplate = template
relation.RelationName = "FirstChild"
relation.ParentColumnNames.Add("Id")
relation.ChildColumnNames.Add("ParentId")
RadGridView1.Relations.Add(relation)
Dim template2 As New GridViewTemplate()
template2.DataSource = dt3
template2.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill
RadGridView1.MasterTemplate.Templates.Add(template2)
Dim relation2 As New GridViewRelation(RadGridView1.MasterTemplate)
relation2.ChildTemplate = template2
relation2.RelationName = "SecondChild"
relation2.ParentColumnNames.Add("Id")
relation2.ChildColumnNames.Add("ParentId")
RadGridView1.Relations.Add(relation2)
AddHandler Me.RadGridView1.ChildViewExpanding, AddressOf ChildViewExpanding
End Sub
Private Sub RadGridView1_ViewCellFormatting(sender As Object, e As Telerik.WinControls.UI.CellFormattingEventArgs) _
Handles RadGridView1.ViewCellFormatting
Dim cell As GridDetailViewCellElement = TryCast(e.CellElement, GridDetailViewCellElement)
Dim expanderCell As GridGroupExpanderCellElement = TryCast(e.CellElement, GridGroupExpanderCellElement)
If expanderCell IsNot Nothing AndAlso TypeOf e.CellElement.RowElement Is GridDataRowElement Then
Dim hierarchyRow As GridViewHierarchyRowInfo = DirectCast(expanderCell.RowInfo, GridViewHierarchyRowInfo)
If Not IsExpandable(hierarchyRow) Then
expanderCell.Expander.Visibility = Telerik.WinControls.ElementVisibility.Hidden
Else
expanderCell.Expander.Visibility = Telerik.WinControls.ElementVisibility.Visible
End If
ElseIf cell IsNot Nothing Then
Dim hierarchyRow As GridViewHierarchyRowInfo = DirectCast(DirectCast(cell.RowInfo, GridViewDetailsRowInfo).Owner, _
GridViewHierarchyRowInfo)
For i As Integer = 0 To cell.PageViewElement.Items.Count - 1
Dim item As RadPageViewItem = cell.PageViewElement.Items(i)
Dim viewInfo As GridViewInfo = hierarchyRow.Views(i)
item.Text = "Child Template " & i
If viewInfo.ChildRows.Count = 0 Then
If i = 0 AndAlso i < cell.PageViewElement.Items.Count - 1 Then
cell.PageViewElement.Items(i + 1).IsSelected = True
End If
item.Visibility = Telerik.WinControls.ElementVisibility.Hidden
Else
item.Visibility = Telerik.WinControls.ElementVisibility.Visible
End If
Next
End If
End Sub
Private Function IsExpandable(hierarchyRow As GridViewHierarchyRowInfo) As Boolean
For Each view As GridViewInfo In hierarchyRow.Views
If view.ChildRows.Count > 0 Then
Return True
End If
Next
Return False
End Function
Workaround:
AddHandler Me.RadGridView1.ChildViewExpanding, AddressOf RadGridView1_ChildViewExpanding
AddHandler Me.RadGridView1.MouseDown, AddressOf RadGridView_MouseDown
Private Sub RadGridView1_ChildViewExpanding(sender As Object, e As ChildViewExpandingEventArgs)
If lastClicked IsNot Nothing AndAlso e.ParentRow.Equals(lastClicked) Then
e.Cancel = False
Else
e.Cancel = True
End If
End Sub
Dim lastClicked As GridViewRowInfo
Private Sub RadGridView_MouseDown(sender As Object, e As MouseEventArgs)
Dim expander As GridExpanderItem = TryCast(Me.RadGridView1.ElementTree.GetElementAtPoint(e.Location), GridExpanderItem)
If expander IsNot Nothing Then
lastClicked = DirectCast(expander.Parent, GridGroupExpanderCellElement).RowInfo
End If
End Sub
To reproduce: - Add a checkbox column and hide some of the cells. - Change some values and then click on empty cell. - Exception occurs in OnMouseDownLeft method (GridRowBeahvior class) Workaround: Hide the checkbox only.
To reproduce:
1. Add a RadMultiColumnComboBox and populate it with data.
2. Set the DropDownStyle property of the control to DropDownList
3. Set the EditorControl.AllowSearchRow and the AutoSizeDropDownToBestFit properties to true .
4. When you open the drop down and try to use the search row (e.g. clicking over the arrow buttons), the drop down is closed.
Workaround:
public partial class RadForm1 : Telerik.WinControls.UI.RadForm
{
public RadForm1()
{
InitializeComponent();
this.radMultiColumnComboBox1.EditorControl.AllowSearchRow = true;
this.radMultiColumnComboBox1.DropDownStyle = Telerik.WinControls.RadDropDownStyle.DropDownList;
this.radMultiColumnComboBox1.DropDownClosing += RadMultiColumnComboBox1_DropDownClosing;
}
private void RadMultiColumnComboBox1_DropDownClosing(object sender, RadPopupClosingEventArgs args)
{
Point position = this.radMultiColumnComboBox1.EditorControl.PointToClient(Cursor.Position);
Telerik.WinControls.RadElement searchElement = this.radMultiColumnComboBox1.EditorControl.ElementTree.GetElementAtPoint(position);
if (searchElement != null)
{
GridSearchCellElement parent = searchElement.FindAncestor<GridSearchCellElement>();
if (parent != null)
{
args.Cancel = true;
}
}
}
}
1. Create a new project and setup hierarchy 2. Add a large number of rows as child rows to the last row at first level 3. Run the project and try to expand the last row
- Create a new project containing RadGridView - Build hierarchy with large text data in cells - Set the AutoSizeRows property to true and AutoSizeColumnMode to Fill - Run the project, scroll down and try to click on a cell
I have the following logic for my View, which has a RadGridView control (add to form at design-time).
GUI is a lightweight view, Controller does the heavy lifting. That part is all good.
However setting the column name and column autosize stuff is a little more "over-complicated" than I'd wish to see. It all works though.
Would be nice to have a "GridViewTextBoxColumnAttribute" as per below, for properties on Custom datasource objects to achieve the same thing in a more concise way.
Or am I missing something and there is a much easier way to do what I want?
I have a number of datasource classes: MyObject, MyCar, MyDog, MyWhatever... that ALL have different property names and datatypes, but may or may-not have the same column name or MasterTemplate style.
Also BestFitColumns is a function of the MasterTemplate, would be nice if it were a property for consistency sake (call to internal function encapsulated in the Set etc), as from a Telerik user's perspective it's just an enum. Then it would be setable in the SmartTag window as well, as functions can't be assigned to.
public partial class RadForm1 : Telerik.WinControls.UI.RadForm, IView
{
public RadForm1)
{
InitializeComponent();
}
private void RadForm1_Load(object sender, EventArgs e)
{
var x = new Controller();
x.SetTemplate(this);
}
public Telerik.WinControls.UI.RadGridView RadGridView()
{
return this.radGridView1;
}
}
public class Controller
{
public void SetTemplate(IView view)
{
var View_RadGrid = view.RadGridView();
View_RadGrid.MasterTemplate.AutoGenerateColumns = false;
View_RadGrid.MasterTemplate.AutoGenerateHierarchy = false;
View_RadGrid.MasterTemplate.AllowColumnResize = false;
View_RadGrid.MasterTemplate.BestFitColumns(Telerik.WinControls.UI.BestFitColumnMode.AllCells);
var cols = new List<Telerik.WinControls.UI.GridViewDataColumn>()
{
new Telerik.WinControls.UI.GridViewTextBoxColumn("DisplayName1"),
new Telerik.WinControls.UI.GridViewTextBoxColumn("DisplayName2")
};
View_RadGrid.MasterTemplate.Columns.AddRange(cols.ToArray());
View_RadGrid.DataSource = new List<MyObject>()
{
new MyObject() { DisplayName1 = "1", DisplayName2 = "2" },
new MyObject() { DisplayName1 = "3", DisplayName2 = "4" }
};
}
private class MyObject
{
[GridViewTextBoxColumnAttribute("DisplayName1", BestFitColumn = Telerik.WinControls.UI.BestFitColumnMode.AllCells, AllowColumnResize = false)]
public string DisplayName1 { get; set; }
[GridViewTextBoxColumnAttribute("DisplayName2", BestFitColumn = Telerik.WinControls.UI.BestFitColumnMode.AllCells, AllowColumnResize = false)]
public string DisplayName2 { get; set; }
}
}
public interface IView
{
Telerik.WinControls.UI.RadGridView RadGridView();
}
[System.AttributeUsage(System.AttributeTargets.Property)]
public class GridViewTextBoxColumnAttribute : System.Attribute
{
private string FieldName;
public Telerik.WinControls.UI.BestFitColumnMode BestFitColumn;
public bool AllowColumnResize;
public GridViewTextBoxColumnAttribute(string fieldName)
{
this.FieldName = fieldName;
}
}How to reproduce:
1. Click DrugName Filter Icon.
2. Uncheck Combivent
3. OK
4. Click name Filter Icon
5. Uncheck Christoff
6. OK
7. Click DrugName Filter Icon
8. Uncheck Dilantin
9. OK
In this scenario the grid should display only 2 rows but it displays 3.
public partial class RadForm1 : Telerik.WinControls.UI.RadForm
{
public List<Drug> DrugList { get; set; }
public RadForm1()
{
InitializeComponent();
DrugList = new List<Drug>();
LoadDrugList();
radGridView1.DataSource = DrugList;
radGridView1.EnableFiltering = true;
this.radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
this.radGridView1.MultiSelect = true;
}
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
radGridView1.MasterTemplate.ShowFilteringRow = false;
radGridView1.MasterTemplate.ShowHeaderCellButtons = true;
}
void LoadDrugList()
{
DrugList.Add(new Drug { Dosage = 25, DrugName = "Indocin", Name = "David"});
DrugList.Add(new Drug { Dosage = 50, DrugName = "Enebrel", Name = "Sam" });
DrugList.Add(new Drug { Dosage = 10, DrugName = "Hydralazine", Name = "Christoff"});
DrugList.Add(new Drug { Dosage = 21, DrugName = "Combivent", Name = "Janet"});
DrugList.Add(new Drug { Dosage = 100, DrugName = "Dilantin", Name = "Melanie"});
}
}
Workaround: use a custom filter popup
public partial class RadForm1 : Telerik.WinControls.UI.RadForm
{
public List<Drug> DrugList { get; set; }
public RadForm1()
{
InitializeComponent();
DrugList = new List<Drug>();
LoadDrugList();
radGridView1.DataSource = DrugList;
radGridView1.EnableFiltering = true;
this.radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
this.radGridView1.MultiSelect = true;
this.radGridView1.FilterPopupRequired += RadGridView1_FilterPopupRequired;
}
private void RadGridView1_FilterPopupRequired(object sender, FilterPopupRequiredEventArgs e)
{
e.FilterPopup = new CustomRadListFilterPopup(e.Column);
}
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
radGridView1.MasterTemplate.ShowFilteringRow = false;
radGridView1.MasterTemplate.ShowHeaderCellButtons = true;
}
void LoadDrugList()
{
DrugList.Add(new Drug { Dosage = 25, DrugName = "Indocin", Name = "David"});
DrugList.Add(new Drug { Dosage = 50, DrugName = "Enebrel", Name = "Sam" });
DrugList.Add(new Drug { Dosage = 10, DrugName = "Hydralazine", Name = "Christoff"});
DrugList.Add(new Drug { Dosage = 21, DrugName = "Combivent", Name = "Janet"});
DrugList.Add(new Drug { Dosage = 100, DrugName = "Dilantin", Name = "Melanie"});
}
}
public class CustomRadListFilterPopup : RadListFilterPopup
{
public CustomRadListFilterPopup(GridViewDataColumn dataColumn)
: base(dataColumn)
{
}
protected override void OnButtonOkClick(EventArgs e)
{
FilterMenuTreeItem treeMenuItem = this.Items.FirstOrDefault(i => i is FilterMenuTreeItem) as FilterMenuTreeItem;
if (treeMenuItem == null)
{
base.OnButtonOkClick(e);
}
FilterMenuTreeElement listFilterElement = treeMenuItem.TreeElement;
FilterOperator filterOperator = FilterOperator.IsEqualTo;
switch (listFilterElement.SelectedMode)
{
case ListFilterSelectedMode.All:
filterOperator = FilterOperator.None;
break;
case ListFilterSelectedMode.Null:
filterOperator = FilterOperator.IsNull;
break;
case ListFilterSelectedMode.NotNull:
filterOperator = FilterOperator.IsNotNull;
break;
}
if (filterOperator != FilterOperator.IsEqualTo)
{
SetFilterOperator(filterOperator);
this.ClosePopup(RadPopupCloseReason.CloseCalled);
}
else
{
CompositeFilterDescriptor compositeFilterDescriptor = new CompositeFilterDescriptor();
compositeFilterDescriptor.PropertyName = this.DataColumn.Name;
RadListFilterDistinctValuesTable distinctValues = this.GetDistinctValuesTable();
string blanksKey = RadGridLocalizationProvider.CurrentProvider.GetLocalizedString(RadGridStringId.FilterMenuBlanks);
bool blanks = listFilterElement.SelectedValues.Contains(blanksKey);
compositeFilterDescriptor.LogicalOperator = FilterLogicalOperator.And;
foreach (DictionaryEntry entry in distinctValues)
{
object key = entry.Key;
if (string.IsNullOrEmpty(Convert.ToString(key)))
{
key = blanksKey;
}
if (this.DataColumn is GridViewDateTimeColumn || this.DataColumn.DataType == typeof(DateTime) || this.DataColumn.DataType == typeof(DateTime?))
{
DateTime dateTime;
if (DateTime.TryParse(key.ToString(), out dateTime))
{
object dataKey;
if (RadDataConverter.Instance.TryFormat(treeMenuItem.TreeElement.GroupedDateValues ? dateTime.Date : dateTime, typeof(string), this.DataColumn, out dataKey) == null)
{
key = dataKey;
}
}
}
if (!listFilterElement.SelectedValues.Contains(key))
{
foreach (object value in (ArrayList)entry.Value)
{
FilterDescriptor descriptor;
if (value == DBNull.Value)
{
descriptor = new FilterDescriptor(this.DataColumn.Name, FilterOperator.IsNotEqualTo, null);
}
else if (this.DataColumn is GridViewDateTimeColumn || this.DataColumn.DataType == typeof(DateTime) || this.DataColumn.DataType == typeof(DateTime?))
{
descriptor = new DateFilterDescriptor(this.DataColumn.Name, FilterOperator.IsNotEqualTo, (DateTime?)value, false);
}
else
{
descriptor = new FilterDescriptor(this.DataColumn.Name, FilterOperator.IsNotEqualTo, value);
}
compositeFilterDescriptor.FilterDescriptors.Add(descriptor);
}
}
}
if (this.DataColumn.FilterDescriptor != null)
{
CompositeFilterDescriptor compositeFilter = this.DataColumn.FilterDescriptor as CompositeFilterDescriptor;
if (compositeFilter != null)
{
foreach (var item in compositeFilter.FilterDescriptors)
{
if (listFilterElement.SelectedValues.Contains(item.Value))
{
continue;
}
FilterDescriptor descriptor = new FilterDescriptor(this.DataColumn.Name, FilterOperator.IsNotEqualTo, item.Value);
compositeFilterDescriptor.FilterDescriptors.Add(descriptor);
}
}
else if(!listFilterElement.SelectedValues.Contains(this.DataColumn.FilterDescriptor.Value))
{
FilterDescriptor descriptor = new FilterDescriptor(this.DataColumn.Name, FilterOperator.IsNotEqualTo, this.DataColumn.FilterDescriptor.Value);
compositeFilterDescriptor.FilterDescriptors.Add(descriptor);
}
}
this.FilterDescriptor = compositeFilterDescriptor;
OnFilterConfirmed();
}
}
}
Workaround:
private void radGridView1_ConditionalFormattingFormShown(object sender, EventArgs e)
{
ConditionalFormattingForm f = sender as ConditionalFormattingForm;
if (f != null)
{
f.Width += 5;
}
}
To reproduce:
Add a RadGridView and use the following code. When you expand the first row, the vertical scrollbar is not correct. Scrolling down changes its size. However, if you expand the last row, it takes few seconds to open.
Second scenario:
In addition of the following code, if you change the TableElement.PageViewMode to PageViewMode.ExplorerBar, expanding the first row takes few seconds to load the hierarchical data as well.
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
List<Item> items = new List<Item>();
List<SubItem> subItems = new List<SubItem>();
for (int i = 1; i <= 3; i++)
{
Item item = new Item(i, "Item" + i);
for (int j = 1000; j <= 2010; j++)
{
subItems.Add(new SubItem(j, "SubItem" + j, i));
}
items.Add(item);
}
this.radGridView1.DataSource = items;
this.radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
GridViewTemplate template = new GridViewTemplate();
template.ReadOnly = true;
template.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
GridViewRelation relation = new GridViewRelation(this.radGridView1.MasterTemplate, template);
relation.ParentColumnNames.Add("Id");
relation.ChildColumnNames.Add("ItemId");
this.radGridView1.MasterTemplate.Templates.Add(template);
this.radGridView1.Relations.Add(relation);
template.DataSource = subItems;
}
}
public class Item
{
public int Id { get; set; }
public string Title { get; set; }
public Item(int id, string title)
{
this.Id = id;
this.Title = title;
}
}
public class SubItem
{
public int Id { get; set; }
public int ItemId { get; set; }
public string Name { get; set; }
public SubItem(int id, string name, int itemId)
{
this.Id = id;
this.ItemId = itemId;
this.Name = name;
}
}