Search as you type not working

6 posts, 0 answers
  1. Roy
    Roy avatar
    9 posts
    Member since:
    Dec 2014

    Posted 19 Aug Link to this post

    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));
        }
    }
  2. Yoan
    Admin
    Yoan avatar
    1070 posts

    Posted 24 Aug Link to this post

    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.
  3. UI for WPF is Visual Studio 2017 Ready
  4. Roy
    Roy avatar
    9 posts
    Member since:
    Dec 2014

    Posted 24 Aug Link to this post

    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

  5. Yoan
    Admin
    Yoan avatar
    1070 posts

    Posted 26 Aug Link to this post

    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.
  6. Roy
    Roy avatar
    9 posts
    Member since:
    Dec 2014

    Posted 31 Aug Link to this post

    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?

  7. Yoan
    Admin
    Yoan avatar
    1070 posts

    Posted 02 Sep Link to this post

    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.
Back to Top
UI for WPF is Visual Studio 2017 Ready