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

Programmatically Set Filters

28 Answers 463 Views
GridView
This is a migrated thread and some comments may be shown as answers.
David Hedden
Top achievements
Rank 1
David Hedden asked on 05 Aug 2010, 04:44 PM
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

28 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 06 Aug 2010, 06:36 AM
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
0
David Hedden
Top achievements
Rank 1
answered on 09 Aug 2010, 02:27 PM
Is there an example that shows how to do this?
0
Accepted
Vlad
Telerik team
answered on 09 Aug 2010, 02:32 PM
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
0
David Hedden
Top achievements
Rank 1
answered on 09 Aug 2010, 03:01 PM
Is there anyway to clear this filter at runtime?
0
Vlad
Telerik team
answered on 09 Aug 2010, 03:33 PM
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
0
David Hedden
Top achievements
Rank 1
answered on 09 Aug 2010, 04:04 PM
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?
0
Vlad
Telerik team
answered on 09 Aug 2010, 04:35 PM
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
0
Irene
Top achievements
Rank 2
answered on 11 Nov 2010, 11:44 PM
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
0
Veselin Vasilev
Telerik team
answered on 12 Nov 2010, 10:35 AM
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
0
Irene
Top achievements
Rank 2
answered on 12 Nov 2010, 11:03 PM

Guys, YOU ROCK!

 

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

 

Irene

0
Peter
Top achievements
Rank 1
answered on 08 Apr 2011, 11:06 AM
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
0
Rossen Hristov
Telerik team
answered on 08 Apr 2011, 04:36 PM
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
0
Peter
Top achievements
Rank 1
answered on 08 Apr 2011, 04:57 PM
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.

0
Rossen Hristov
Telerik team
answered on 08 Apr 2011, 05:02 PM
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
0
Peter
Top achievements
Rank 1
answered on 11 Apr 2011, 01:02 PM
Thank you Ross, that solved my problem
0
Doug
Top achievements
Rank 1
answered on 05 Apr 2012, 02:13 PM
Is there another link that shows how to save/load the filter settings? The one posted doesn't appear to work anymore.
0
Vlad
Telerik team
answered on 05 Apr 2012, 02:15 PM
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 >>

0
Doug
Top achievements
Rank 1
answered on 05 Apr 2012, 02:23 PM
It appears we aren't using the latest and greatest yet. Is a version for the Silverlight 4 controls still available anywhere?
0
Vlad
Telerik team
answered on 05 Apr 2012, 02:25 PM
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 >>

0
Sven J
Top achievements
Rank 2
answered on 30 May 2012, 10:04 AM
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

0
Rossen Hristov
Telerik team
answered on 30 May 2012, 10:10 AM
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 >>

0
Sven J
Top achievements
Rank 2
answered on 30 May 2012, 11:00 AM
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



0
Rossen Hristov
Telerik team
answered on 30 May 2012, 11:09 AM
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 >>

0
Rossen Hristov
Telerik team
answered on 30 May 2012, 11:38 AM
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 >>

0
Peter Hedley
Top achievements
Rank 1
answered on 13 May 2015, 10:13 AM

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.

0
Dimitrina
Telerik team
answered on 14 May 2015, 08:55 AM
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
0
Peter Hedley
Top achievements
Rank 1
answered on 14 May 2015, 11:06 AM

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.

0
Dimitrina
Telerik team
answered on 14 May 2015, 12:41 PM
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
Tags
GridView
Asked by
David Hedden
Top achievements
Rank 1
Answers by
Vlad
Telerik team
David Hedden
Top achievements
Rank 1
Irene
Top achievements
Rank 2
Veselin Vasilev
Telerik team
Peter
Top achievements
Rank 1
Rossen Hristov
Telerik team
Doug
Top achievements
Rank 1
Sven J
Top achievements
Rank 2
Peter Hedley
Top achievements
Rank 1
Dimitrina
Telerik team
Share this question
or