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

Filter ObservableCollection binded to RadGridView

2 Answers 100 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Sivakumar
Top achievements
Rank 1
Sivakumar asked on 26 Jun 2013, 11:13 AM

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 Answers, 1 is accepted

Sort by
0
Sivakumar
Top achievements
Rank 1
answered on 26 Jun 2013, 11:19 AM
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 ?
0
Dimitrina
Telerik team
answered on 01 Jul 2013, 09:08 AM
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 >>
Tags
General Discussions
Asked by
Sivakumar
Top achievements
Rank 1
Answers by
Sivakumar
Top achievements
Rank 1
Dimitrina
Telerik team
Share this question
or