I've just downloaded the UI for WPF Q2 2016. I'm trying to use the Search as you type feature, but it's throwing exceptions.
My XAML looks as follows:
<telerik:RadGridView ItemsSource="{Binding Table}" AutoGenerateColumns="True"></telerik:RadGridView>And my ViewModel:
public class TestViewModel : INotifyPropertyChanged{ private DataTable _table; public event PropertyChangedEventHandler PropertyChanged; public TestViewModel() { var table = new DataTable(); table.Columns.Add("StringValue", typeof(string)); for (int i = 0; i < 100; i++) { table.Rows.Add($"String Value {i}"); } Table = table; } public DataTable Table { get { return _table; } set { _table = value; OnPropertyChanged(nameof(Table)); OnPropertyChanged(nameof(View)); } } public DataView View { get { return Table.DefaultView; } } protected virtual void OnPropertyChanged(string propertyName = null) { PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); }}
When thrying to search as you type I get an ArgumentException with message: "Column '[StringValue]' does not belong to table".
I've tried binding to the Table as well as the DefaultView of the table, but the results are the same.
public class TestViewModel : INotifyPropertyChanged{ private DataTable _table; public event PropertyChangedEventHandler PropertyChanged; public TestViewModel() { var table = new DataTable(); table.Columns.Add("StringValue", typeof(string)); for (int i = 0; i < 100; i++) { table.Rows.Add($"String Value {i}"); } Table = table; } public DataTable Table { get { return _table; } set { _table = value; OnPropertyChanged(nameof(Table)); OnPropertyChanged(nameof(View)); } } public DataView View { get { return Table.DefaultView; } } protected virtual void OnPropertyChanged(string propertyName = null) { PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); }}public class TestViewModel : INotifyPropertyChanged{ private DataTable _table; public event PropertyChangedEventHandler PropertyChanged; public TestViewModel() { var table = new DataTable(); table.Columns.Add("StringValue", typeof(string)); for (int i = 0; i < 100; i++) { table.Rows.Add($"String Value {i}"); } Table = table; } public DataTable Table { get { return _table; } set { _table = value; OnPropertyChanged(nameof(Table)); OnPropertyChanged(nameof(View)); } } public DataView View { get { return Table.DefaultView; } } protected virtual void OnPropertyChanged(string propertyName = null) { PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); }}public class TestViewModel : INotifyPropertyChanged{ private DataTable _table; public event PropertyChangedEventHandler PropertyChanged; public TestViewModel() { var table = new DataTable(); table.Columns.Add("StringValue", typeof(string)); for (int i = 0; i < 100; i++) { table.Rows.Add($"String Value {i}"); } Table = table; } public DataTable Table { get { return _table; } set { _table = value; OnPropertyChanged(nameof(Table)); OnPropertyChanged(nameof(View)); } } public DataView View { get { return Table.DefaultView; } } protected virtual void OnPropertyChanged(string propertyName = null) { PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); }}public class TestViewModel : INotifyPropertyChanged{ private DataTable _table; public event PropertyChangedEventHandler PropertyChanged; public TestViewModel() { var table = new DataTable(); table.Columns.Add("StringValue", typeof(string)); for (int i = 0; i < 100; i++) { table.Rows.Add($"String Value {i}"); } Table = table; } public DataTable Table { get { return _table; } set { _table = value; OnPropertyChanged(nameof(Table)); OnPropertyChanged(nameof(View)); } } public DataView View { get { return Table.DefaultView; } } protected virtual void OnPropertyChanged(string propertyName = null) { PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); }}5 Answers, 1 is accepted
As it turns out, this is an issue in RadGridView. I have logged it in our feedback portal as a bug report. You can track its progress on the following link - Argument Exception is thrown when filtering through the search panel and the grid is bound to a DataTable.
I have also updated your Telerik points.
Regards,
Yoan
Telerik by Progress
Hello Yoan,
Thanks for the update. Is there currently a workarround possible by implementing the search itself (e.g. by creating a custom FilterDescriptor )? I can't find any extension points to customize the search as you type.
Regards Roy
Actually, we have already fixed the issue. The fix will be available for you with our next internal build (next Monday).
Regards,
Yoan
Telerik by Progress
The Example I posted still doens't work. When I change te binding to the DefaultView searching is possible.
Another Issue I have that it is not possible to search in Custom types. How do I extend the search as I type to support searching in custom types?
Generally, using the DefaultView is the recommended approach as it provides PropertyChanged notifications.
As for the other question:
May I ask you to clarify what you mean by custom type? Are you binding to complex properties or to a specific business object property?
Regards,
Yoan
Telerik by Progress