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

Need assistance with adding Label to XAML that translates current Filters and Sorts

1 Answer 16 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Kathleen
Top achievements
Rank 1
Kathleen asked on 07 May 2010, 04:59 PM
I have a gridview control bound to a domaindatasource via the MVVM pattern.
I have a label on the form that I would like to provide feedback to the user:

"Sorted by First Name, Filtered by Last Name like 'Jones'"

My first attempt was to simply bind the label content to the DomainDataSouce FilterDescriptors, passed to an IValueConverter to create the concated description.  However, it seems that changing the column filters on the gridView doesn't actually change the FilterDescriptors collection on the DomainDataSource.

My second attempt was to bind the label content to the gridView.FilterDescriptors collection, also passed to an IValueConverter to create the concated description.   However, it seems that changes to FilterDescriptors collection do not fire an OnPropertyChanged event, so the value never changes.

I'm sure I'm just overlooking something really simple, but I couldn't find anything similar in the blogs or forums.

Here is my XAML:

 

 

 

<dataInput:Label Style="{StaticResource PanelHeaderStyle}"

 

 

 

HorizontalAlignment="Left"

 

 

 

Content="{Binding FilterDescriptors, Mode=OneWay,

 

 

 

ElementName=gridView, Converter={StaticResource filterDescriptorConverter}}"

 

 

 

Grid.Row="0"/>

 


Here is the converter:

 

 

public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)

 

{

Telerik.Windows.Data.

 

FilterDescriptorCollection filters;

 

 

 

try

 

{

filters = value

 

as Telerik.Windows.Data.FilterDescriptorCollection;

 

}

 

 

catch (Exception)

 

{

 

 

return string.Empty;

 

}

 

 

if (filters==null) return string.Empty;

 

 

 

if (filters.Count>2)

 

 

 

return string.Format(EntityNames.FilterByName, filters.Count.ToString());

 

 

 

foreach (var filter in filters)

 

{

 

 

// build a filter string such as "Filtered by 'Title'='Book' and 'Subject'='Something'

 

 

}

 

 

// replace with build filter string.

 

 

 

return string.Empty;

 

}





1 Answer, 1 is accepted

Sort by
0
Pavel Pavlov
Telerik team
answered on 10 May 2010, 01:33 PM
Hello Kathleen,

Maybe you can subscribe to the RadGridView.Filtered and RadGridView.Sorted events and update the label text whenever these are fired ?

Kind regards,
Pavel Pavlov
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.
Tags
GridView
Asked by
Kathleen
Top achievements
Rank 1
Answers by
Pavel Pavlov
Telerik team
Share this question
or