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

Raise Filtered event on custom filtering

3 Answers 179 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Victor
Top achievements
Rank 1
Victor asked on 11 Dec 2013, 10:24 AM
Hello everyone, first of all, excuse me for my broken english.

I've developed a custom filters for DateTime and Time columns of my RadGridView.

Filters work great, but once I finish filtering I need to raise the Filtered event of grid, so the ViewModel will communicate with my RIA service sending all grid filter descriptors.

How do I raise programmatically the Filtered event?

Thanks in advance.

PS- I hope you understand what I'm trying to explain. If not, do not hesitate to ask me.

3 Answers, 1 is accepted

Sort by
0
Victor
Top achievements
Rank 1
answered on 13 Dec 2013, 08:43 AM
Nobody knows how to fire the Filtered event?

The grid is filtering, but the event is not firing...any idea?

Thanks in advance.
0
Dimitrina
Telerik team
answered on 13 Dec 2013, 09:55 AM
Hello,

The Filtered event is an UI event. It will only be raised on a user interaction.

Another way to encounter that a filtering has been performed would be to subscribe for the CollectionChanged event of the FilterDescriptors collection.

Regards,
Didie
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
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 >>
0
David
Top achievements
Rank 1
answered on 02 May 2016, 02:19 PM

Once you have this code:

 

public void Prepare( Telerik.Windows.Controls.GridViewColumn column ) {
    _column = column as GridViewBoundColumnBase;
    _gridView = column.Parent as RadGridView;
    if( _column == null ) {
        return;
    }
}

 

You have to call in your function that applies the filter:

 

private void applyCheckboxFilter( CheckBox cb, int value ) {
 
    Telerik.Windows.Controls.GridView.IColumnFilterDescriptor okActionFilter;
    okActionFilter = _column.ColumnFilterDescriptor;
    _filterDescriptors.Clear();
    _filterDescriptors.Add( okActionFilter );
 
    if( cb.IsChecked == true ) {
 
        okActionFilter.DistinctFilter.AddDistinctValue( value );
    } else if( cb.IsChecked == false ) {
 
        okActionFilter.DistinctFilter.RemoveDistinctValue( value );
    }
     
    IsActive = okActionFilter.DistinctFilter.FilterDescriptors.Count() > 0;
 
    _gridView.RaiseEvent( new GridViewFilteredEventArgs( _filterDescriptors, null ) );
}

 

The last line is what you want.

 

David.

Tags
GridView
Asked by
Victor
Top achievements
Rank 1
Answers by
Victor
Top achievements
Rank 1
Dimitrina
Telerik team
David
Top achievements
Rank 1
Share this question
or