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

Update filter when property is changed in code

3 Answers 155 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Aksel
Top achievements
Rank 1
Aksel asked on 05 Dec 2012, 10:29 AM
I'm using the RadGridView to display a status list to the user, containing all the alarms of the system.
This list is usually filtered on all active alarms, meaning that once an alarm is acknowledged by the user or the system, it should disappear from the filtered list. (but not from the collection, only the filtered list).

However, when the acknowledged property (complete with OnPropertyChanged) is changed, the grid now displays the changed value, but the filter does not filter the item away. How can I achieve this?

I made a sample project describing the problem, but I can't upload it.

3 Answers, 1 is accepted

Sort by
0
Rossen Hristov
Telerik team
answered on 05 Dec 2012, 10:43 AM
Hello,

You will have to "tell" the grid that the data has changed as described in this article.

Another approach is to remove the item, change its values and then add it again.

A third approach is to call the Rebind method of the grid.

Kind regards,
Rossen Hristov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Aksel
Top achievements
Rank 1
answered on 05 Dec 2012, 11:52 AM
It seems that I can solve it by removing by removing all filters in the column I want to monitor and add them back.

private void UpdateFilter(string column)
{
    var distinctValues = AlarmGrid.Columns[column].ColumnFilterDescriptor.DistinctFilter;
    var objects = distinctValues.DistinctValues.ToList();
    distinctValues.Clear();
    foreach (var o in objects)
    {
        distinctValues.AddDistinctValue(o);
    }
}

Is there any issues with this approach?
0
Rossen Hristov
Telerik team
answered on 05 Dec 2012, 12:07 PM
Hello,

Anything that causes re-creation of the view will do it. Touching the FilterDescriptor is one of them.

But you don't really have to do all of this -- you can simply call the Rebind method -- it will do the same thing -- scrap the current view and create it again.

All the best,
Rossen Hristov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
GridView
Asked by
Aksel
Top achievements
Rank 1
Answers by
Rossen Hristov
Telerik team
Aksel
Top achievements
Rank 1
Share this question
or