Filter ObservableCollection binded to RadGridView

3 posts, 0 answers
  1. Sivakumar
    Sivakumar avatar
    8 posts
    Member since:
    Jun 2013

    Posted 26 Jun 2013 Link to this post

    Hi,
      
    <telerik:RadGridView x:Name="radGridView" ShowGroupPanel="False" AutoGenerateColumns="False" ItemsSource="{Binding DataList}">
    .....

    </telerik:RadGridView>

    ViewModel
    ----------

            private ObservableCollection<ClientDataRealizationModel> _dataList
            public ObservableCollection<ClientDataRealizationModel> DataList
            {
                get { return _dataList}
                set { _dataList= value; OnPropertyChanged("DataList"); }
            }

            private void OnFilter(string year)
            {
              var list = _dataList.Where(x => x.Year == year).Select(x => x);
               _dataList= new ObservableCollection<DataModel>(list);
            }



    The filtered data is not showing. Should we refresh the grid ? Can anyone help me out to solve this issue.
  2. Sivakumar
    Sivakumar avatar
    8 posts
    Member since:
    Jun 2013

    Posted 26 Jun 2013 Link to this post

    Hi,
      I solved using this way..

     private void OnFilter(string year)
            {
              var list = _dataList.Where(x => x.Year == year).Select(x => x);
               _dataList= new ObservableCollection<DataModel>(list);

                _dataList.Clear();
                foreach (var item in list)
                {
                    _dataList.Add(item);
                }
            }


    Is there any way to filter the Grid without using the above way ? Bcoz i'm using backup list . How to get rid of this ?
  3. UI for WPF is Visual Studio 2017 Ready
  4. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 01 Jul 2013 Link to this post

    Hi,

    The ItemsSource of the GridView will be updated once a CollectionChanged event of the bound source collection is raised.
     

    Regards,
    Didie
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
Back to Top