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
You can add predefined FilterDescriptor to the grid FilterDescriptors to achieve your goal.
Greetings,Vlad
the Telerik team
Here is an example:
Vlad
the Telerik team
You can call grid.FilterDescriptors.Clear().
Best wishes,Vlad
the Telerik team
You can force the grid filtering at any time not only on initial load. Just add desired FilterDescriptor.
Regards,Vlad
the Telerik team
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
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
Guys, YOU ROCK!
Thank you sooo much! You saved me a lot of time!
Irene
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
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.
Ross
the Telerik team
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.
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
Here is the new one:
http://demos.telerik.com/silverlight/#PersistenceFramework/GridViewCustomSerialization
Vlad
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
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 >>
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
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 >>
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
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 >>
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 >>
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.
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
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.
We will consider your feedback. Thank you for sharing the solution you came up with to the community.
Regards,
Dimitrina
Telerik