Programmatically Set Filters

29 posts, 1 answers
  1. David Hedden
    David Hedden avatar
    4 posts
    Member since:
    Nov 2009

    Posted 05 Aug 2010 Link to this post

    Hello,
    I'm new to using the Rad Silverlight tools. I have used the ASP.net tools for three years and have decided to begin to move my application from asp to Silverlight. Now onto the question. I currently have a grid that is used to view email, so a email inbox. This inbox is filtered down at run time to who ever is using the application. This was very easy on the RadGrid in asp.net. How do I do this with the silverlight RadGridView.

    <telerik:RadGridView x:Name="emailGrid" Grid.Row="0" AutoGenerateColumns="False" FrozenColumnCount="{Binding Value, ElementName=RadSlider1, Mode=TwoWay}">
                    <telerik:RadGridView.Columns>
                        <telerik:GridViewImageColumn DataMemberBinding="{Binding Flag}" Header="" SortMemberPath="Flag" ImageHeight="15" ImageWidth="15"  />
                        <telerik:GridViewImageColumn DataMemberBinding="{Binding Read}" Header="" ImageHeight="15" ImageWidth="15"  />
                        <telerik:GridViewImageColumn DataMemberBinding="{Binding Attachment}" Header="" ImageHeight="15" ImageWidth="15"  />
                        <telerik:GridViewDataColumn DataMemberBinding="{Binding SETA}" Header="SETA" IsReadOnly="True"/>
                        <telerik:GridViewDataColumn DataMemberBinding="{Binding SEM}" Header="SEM" IsReadOnly="True"/>
                        <telerik:GridViewDataColumn DataMemberBinding="{Binding From}" Header="From" IsReadOnly="True"/>
                        <telerik:GridViewDataColumn DataMemberBinding="{Binding emailTo}" Header="To" IsReadOnly="True"/>
                        <telerik:GridViewDataColumn DataMemberBinding="{Binding Recieved}" Header="Recieved" IsReadOnly="True"/>
                    </telerik:RadGridView.Columns>
                </telerik:RadGridView>

    The column i need to filter on load is the SEM column.

    Thanks,

    David
  2. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 06 Aug 2010 Link to this post

    Hello David,

     You can add predefined FilterDescriptor to the grid FilterDescriptors to achieve your goal. 

    Greetings,
    Vlad
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. DevCraft banner
  4. David Hedden
    David Hedden avatar
    4 posts
    Member since:
    Nov 2009

    Posted 09 Aug 2010 Link to this post

    Is there an example that shows how to do this?
  5. Answer
    Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 09 Aug 2010 Link to this post

    Hi,

     Here is an example:

     <telerik:RadGridView x:Name="RadGridView1" ItemsSource="{Binding}">
                <telerik:RadGridView.FilterDescriptors>
                    <telerik:FilterDescriptor Member="CustomerID" Value="ALFKI" Operator="IsEqualTo"/>
                </telerik:RadGridView.FilterDescriptors>
            </telerik:RadGridView>

    Kind regards,
    Vlad
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  6. David Hedden
    David Hedden avatar
    4 posts
    Member since:
    Nov 2009

    Posted 09 Aug 2010 Link to this post

    Is there anyway to clear this filter at runtime?
  7. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 09 Aug 2010 Link to this post

    Hello,

     You can call grid.FilterDescriptors.Clear().

    Best wishes,
    Vlad
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  8. David Hedden
    David Hedden avatar
    4 posts
    Member since:
    Nov 2009

    Posted 09 Aug 2010 Link to this post

    I see this method filters the data before it gets into the grid. Is there anyway to filter it after the data gets in the grid? This method would be fine if my useser only watched their own inboxes, but sometimes they need to see theirs and someone elses. How would i go about doing this?
  9. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 09 Aug 2010 Link to this post

    Hello,

     You can force the grid filtering at any time not only on initial load. Just add desired FilterDescriptor. 

    Regards,
    Vlad
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  10. Irene
    Irene avatar
    18 posts
    Member since:
    May 2008

    Posted 11 Nov 2010 Link to this post

    Hi,

    I would like to add FilterDescriptors programmatically at the run time, both distinct and field type. Do you have any sample code showing how to do that? Actually I need to save the filters user created and need to reproduce them at a later time. Any idea on any serialization/deserialization trick I can do?

    Thank you very much in advance,

    Irene
  11. Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 12 Nov 2010 Link to this post

    Hi Irene,

    Please check the help topic about the ColumnFilterDescriptor.
    You can also check our Save / Load GridView Settings example - it shows how to store the FilterDescriptors and later load them.

    Hope this helps.

    Kind regards,
    Veselin Vasilev
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  12. Irene
    Irene avatar
    18 posts
    Member since:
    May 2008

    Posted 12 Nov 2010 Link to this post

    Guys, YOU ROCK!

     

    Thank you sooo much! You saved me a lot of time!

     

    Irene

  13. Peter
    Peter avatar
    3 posts
    Member since:
    Apr 2011

    Posted 08 Apr 2011 Link to this post

    Hello,

    I'm using the filtering in the XAML code. How may force it to filter after the grid gets the data? In order than a user may unselect a filter.

    Thank you
  14. Rossen Hristov
    Admin
    Rossen Hristov avatar
    2478 posts

    Posted 08 Apr 2011 Link to this post

    Hello,

    We could not quite understand your exact requirements. Could you please elaborate and provide a simple example to illustrate what exactly you are after?

    Thanks in advance.

    All the best,
    Ross
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  15. Peter
    Peter avatar
    3 posts
    Member since:
    Apr 2011

    Posted 08 Apr 2011 Link to this post

    Sure.

    I have a child grid :
    <DataTemplate x:Name="ChildName" x:Key="Child">
        <StackPanel Margin="15,0,0,0">
            <telerik:RadGridView x:Name="RadGridViewAirlineService" RowDetailsTemplate="{StaticResource ChildService}" RowIndicatorVisibility="Collapsed" CanUserFreezeColumns="False" AutoGenerateColumns="False" ItemsSource="{Binding AirlineServiceRelated}"  IsReadOnly="True">                          
                <telerik:GridViewDataColumn DataMemberBinding="{Binding ServiceLookup.Title}" Header="Service" />
                <telerik:RadGridView.FilterDescriptors>
                    <telerik:FilterDescriptor Member="ServiceLookup.Title"
                        Operator="Contains"
                        Value="Bagages"
                        IsCaseSensitive="False"  />
                </telerik:RadGridView.FilterDescriptors>
    ...    

    Used by a parent grid:
    <telerik:RadGridView x:Name="RadGridViewData"
      RowDetailsTemplate="{StaticResource Child}" Grid.Row="2">

    I would like to filter the child grid. I could not do it in code behind (RadGridViewData.ChildrenOfType<RadGridView>() is always null), so I try to do in XAML, adding the FilterDescriptor.

    The problem is that the result is filtered with "Bagages" without the possiblity to remove this filter and show other values. 

    Thank you for your answer.

  16. Rossen Hristov
    Admin
    Rossen Hristov avatar
    2478 posts

    Posted 08 Apr 2011 Link to this post

    Hi,

    This help topic explains how to find things in the row details.

    Once you have your grid, you can add, remove and manipulate FilterDescriptors from code-behind in any way that you want.

    I hope this helps.

    Kind regards,
    Ross
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  17. Peter
    Peter avatar
    3 posts
    Member since:
    Apr 2011

    Posted 11 Apr 2011 Link to this post

    Thank you Ross, that solved my problem
  18. Doug
    Doug avatar
    6 posts
    Member since:
    Oct 2010

    Posted 05 Apr 2012 Link to this post

    Is there another link that shows how to save/load the filter settings? The one posted doesn't appear to work anymore.
  19. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 05 Apr 2012 Link to this post

    Hi,

     Here is the new one:
    http://demos.telerik.com/silverlight/#PersistenceFramework/GridViewCustomSerialization

    Greetings,
    Vlad
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  20. Doug
    Doug avatar
    6 posts
    Member since:
    Oct 2010

    Posted 05 Apr 2012 Link to this post

    It appears we aren't using the latest and greatest yet. Is a version for the Silverlight 4 controls still available anywhere?
  21. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 05 Apr 2012 Link to this post

    Hi,

     You still have option to download our Silverlight 4 binaries (no installation) however everything else including our demos is Silverlight 5.

    Kind regards,
    Vlad
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  22. Sven J
    Sven J avatar
    26 posts
    Member since:
    Nov 2009

    Posted 30 May 2012 Link to this post

    Hi,

    is there also a working solution which uses the QueryableCollectionView? I'm using MVVM and want to save/load filters but I have only the QueryableCollectionView to my hands...

    Thank you
    Sven

  23. Rossen Hristov
    Admin
    Rossen Hristov avatar
    2478 posts

    Posted 30 May 2012 Link to this post

    Hello,

    The QCV also has FilterDescriptors property. Otherwise, how would you filter it?

    Greetings,
    Ross
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  24. Sven J
    Sven J avatar
    26 posts
    Member since:
    Nov 2009

    Posted 30 May 2012 Link to this post

    Hi,

    correct. The FilterDescriptors property is present but can you explain how to store and reload the filter. When exploring the FilterDescriptors a filter setted by hand/UI is of type ColumnMemberFilterDescriptor. This class can't be created/added programmatically.

    I believe 2012 Q1 removed some FilterDescriptor classes...

    Greetings
    Sven



  25. Rossen Hristov
    Admin
    Rossen Hristov avatar
    2478 posts

    Posted 30 May 2012 Link to this post

    Hi,

    You are right. The QCV has no notion of column filters, since it is not the Grid and has no columns. It only understands FilterDescriptors.

    I am afraid that if you want to preserve column filters, you would have to save/load them on RadGridView itself as described in the article. You can do this with attached behaviors in order to stay in your MVVM design.

    Kind regards,
    Ross
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  26. Rossen Hristov
    Admin
    Rossen Hristov avatar
    2478 posts

    Posted 30 May 2012 Link to this post

    Hi,

    I forgot the article. Here it is.

    Greetings,
    Ross
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  27. Peter Hedley
    Peter Hedley avatar
    6 posts
    Member since:
    Dec 2009

    Posted 13 May 2015 in reply to Rossen Hristov Link to this post

    Hi, having spent too much time grappling with filtering I find Teleriks non-MVVM approach to be disappointing and that's putting it politely.

     Yes, there's a Filter proprty on the QueryableCollectionView but sorry you can't use it.

     Yes, there's a FilterDescriptors property on the QueryableCollectionView but that also does nothing if you set values in your VM.

     Is this likely to be changed in the future?

     Cheers,

    Peter.

  28. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 14 May 2015 Link to this post

    Hi Peter,

    Thank you for sharing your feedback.

    Indeed, we throw an exception internally when the Filter property of the collection is set. The supported filtering through defining FilterDescriptors is a data operation and it is actually done by building and executing a LINQ query over the source collection. For the time being, we have not planned changes in the near future.

    Regards,
    Dimitrina
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  29. Peter Hedley
    Peter Hedley avatar
    6 posts
    Member since:
    Dec 2009

    Posted 14 May 2015 in reply to Dimitrina Link to this post

    Hi Dimitrina,

     Thanks for the note. I solved the problem by setting the Filter property on the ICollectionView wrapped by the QueryableCollectionView - this seems to work fine. Might be an idea to document this as a workaround.

     Cheers,

    Peter.

  30. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 14 May 2015 Link to this post

    Hi Peter,

    We will consider your feedback. Thank you for sharing the solution you came up with to the community.

    Regards,
    Dimitrina
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top
DevCraft banner