Hey,
Unfortunately I have a problem in the sort, filter and group functions in the following case:
Class A
{
string AName;
}
Class B : Class A
{
string BName;
}
Class C
{
A baseClass;
}
The item source is ObservableCollection<C>
I am creating in code behind new GridViewDataColum.
If the binding is
1. " baseClass.AName" =>Everything works.
2. " baseClass.BName " =>The grid view rows are ok.All the data is shown in the correct cells,
But the Filter,Group,Sorting is not working.
What can I do?
8 Answers, 1 is accepted
In class C is the 'baseClass' of type A, or of type B? In my understanding it should be of type B.
Kind regards,Didie
the Telerik team
Maybe this is was missing in my explanation to understand the case.
I am not sure that I understand you the right way. In your previous post you confirmed that the baseClass property in class C is ot type A:
Class C
{
A baseClass;
}
Now I am not sure what does this mean: I build the grid its items only from one type that derives from A?
I have prepared a sample project based on your description. Would you please change my sample so that I can see where you have got a problem?
Didie
the Telerik team
I'm posting the updated XAML and Codebehind since I can't attach the source here:
Mainwindow.xaml:
<Window x:Class="RadGridView_WPF_AR_6.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
xmlns:my="clr-namespace:RadGridView_WPF_AR_6"
xmlns:core="clr-namespace:System;assembly=mscorlib"
Title="MainWindow" Height="700" Width="700">
<Grid>
<telerik:RadGridView
Name="myGrid"
AutoGenerateColumns="False"
Margin="5">
<telerik:RadGridView.Columns>
<telerik:GridViewDataColumn Width="80" DataMemberBinding="{Binding baseClass.AName}" />
<telerik:GridViewDataColumn Width="Auto" DataMemberBinding="{Binding baseClass.BName}" DataType="{x:Type core:String}"/>
</telerik:RadGridView.Columns>
</telerik:RadGridView>
</Grid>
</Window>
MainWindow.xaml.cs:
namespace RadGridView_WPF_AR_6
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
ObservableCollection<C> listC = new ObservableCollection<C>();
listC.Add(new C(new B("class a")));
listC.Add(new C(new B("class c")));
myGrid.ItemsSource = listC;
}
public class A
{
public string AName { get; set; }
public A(string a)
{
this.AName = a;
}
public A()
{
this.AName = "default a";
}
}
public class B : A
{
public string BName { get; set; }
public B(string b)
{
this.BName = b;
}
public B()
{
this.BName = "default b";
}
}
public class C
{
public A baseClass { get; set; }
public C(A baseClass)
{
this.baseClass = baseClass;
}
}
}
}
The problem is with the second column , the one binded to B's property.
Regards,
Maya
Did you check our example?
Maya.
I've checked the provided example.
The problem comes from the fact that baseClass property is from type A which does not have property named "BName" and our data engine cannot create a correct expression in order to get distinct values or to perform sort and group. Bindings on the other hand use reflection in order to get the value, therefore there are data within cells of that column. The only option is to change a little bit your data model.
Let me know if there is something unclear.
Nedyalko Nikolov
the Telerik team