This is a migrated thread and some comments may be shown as answers.

Search as you type not working

5 Answers 207 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Roy
Top achievements
Rank 1
Roy asked on 19 Aug 2016, 07:50 AM

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(thisnew 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(thisnew 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(thisnew 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(thisnew PropertyChangedEventArgs(propertyName));
    }
}

5 Answers, 1 is accepted

Sort by
0
Yoan
Telerik team
answered on 24 Aug 2016, 06:05 AM
Hello Roy,

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
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
0
Roy
Top achievements
Rank 1
answered on 24 Aug 2016, 06:21 AM

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

0
Yoan
Telerik team
answered on 26 Aug 2016, 01:54 PM
Hello 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
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
0
Roy
Top achievements
Rank 1
answered on 31 Aug 2016, 11:32 AM

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?

0
Yoan
Telerik team
answered on 02 Sep 2016, 11:39 AM
Hello Roy,

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
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Tags
GridView
Asked by
Roy
Top achievements
Rank 1
Answers by
Yoan
Telerik team
Roy
Top achievements
Rank 1
Share this question
or