Raise Filtered event on custom filtering

4 posts, 0 answers
  1. Victor
    Victor avatar
    12 posts
    Member since:
    Feb 2011

    Posted 11 Dec 2013 Link to this post

    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.
  2. Victor
    Victor avatar
    12 posts
    Member since:
    Feb 2011

    Posted 13 Dec 2013 Link to this post

    Nobody knows how to fire the Filtered event?

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

    Thanks in advance.
  3. DevCraft banner
  4. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 13 Dec 2013 Link to this post

    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 >>
  5. David
    David avatar
    18 posts
    Member since:
    Apr 2016

    Posted 02 May in reply to Victor Link to this post

    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.

Back to Top