문제

I have telerik RadGridView with columns "status", "Name" and a RadButton with name "Update", when the grid is loaded the rows will have different status like "pending" "unread" and "cleared". When user selects a row with status pending and clicks on button "update" the status will change from pending to cleared. The issue is when we set a filter on status column with "pending" only rows with pending status are shown, here when user selects a row and click on update the status changes to "cleared", as the filter is already set, the row with the cleared status also shown. As we update the row it is not removed from the grid.

when the filter is set on the grid, filter descriptor is set, when am reloading the grid

            dgrid.FilterDescriptors.SuspendNotifications();
            foreach (IColumnFilterDescriptor fd in dgrid.Items.FilterDescriptors)
            {
                //IColumnFilterDescriptor columnFilter = fd;

                Telerik.Windows.Controls.GridViewColumn col = dgrid.Columns[fd.Column.UniqueName];
                IColumnFilterDescriptor columnFilter = col.ColumnFilterDescriptor;

                columnFilter.FieldFilter.Filter1.Value = fd.FieldFilter.Filter1.Value;
                columnFilter.FieldFilter.Filter1.Operator = fd.FieldFilter.Filter1.Operator;
            }
            dgrid.FilterDescriptors.ResumeNotifications();
           dgrid.Items.Refresh();
도움이 되었습니까?

해결책

  1. Store your row items in an ObservableCollection of POCO objects.

  2. Have your POCO object class implement INotifyPropertyChanged interface.

  3. Bind your RadGridView to ICollectionView of POCO objects contained in your ObservableCollection, not the ObservableCollection itself.

  4. When your Status property is changed INotifyPropertyChanged will take care of change notification and all you'll have to do is call Refresh() method of your ICollectionView and your RadGridView will display only items that are specified by the filter...

You might need to apply a few little tweaks along the way but this is a good roadmap to achieving the desired results...

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top