Hello,
we have a RadGridView that is bound (in an MVVM scenario) to a property containing the main data for the grid...
Furthermore three columns have an ItemsSourceBinding to three different properties respectively to specify the "SelectedValueMemberPath" and "DisplayMemberPath".
Unfortunately when we want to group these columns (Drag and Drop onto the top of the grid), the grid shows the Id, i.e. "SelectedValueMemberPath" rather than the Name (DisplayMemberPath).
The same problem can be seen when we want to filter the column and the "Filter Window" shows only the SelectedValueMemberPath rather than the desired DisplayMemberPath.
We currently use version 2010.1.603.35 of the telerik controls....
here is some of our current code:
we have a RadGridView that is bound (in an MVVM scenario) to a property containing the main data for the grid...
Furthermore three columns have an ItemsSourceBinding to three different properties respectively to specify the "SelectedValueMemberPath" and "DisplayMemberPath".
Unfortunately when we want to group these columns (Drag and Drop onto the top of the grid), the grid shows the Id, i.e. "SelectedValueMemberPath" rather than the Name (DisplayMemberPath).
The same problem can be seen when we want to filter the column and the "Filter Window" shows only the SelectedValueMemberPath rather than the desired DisplayMemberPath.
We currently use version 2010.1.603.35 of the telerik controls....
here is some of our current code:
<telerik:RadGridView x:Name="radBerthingSlots" |
AutoGenerateColumns="False" |
IsEnabled="True" |
ItemsSource="{Binding BerthingSlots}" |
SelectedItem="{Binding SelectedBerthingSlot, Mode=TwoWay}" |
CanUserDeleteRows="False" |
<telerik:RadGridView.Columns> |
<telerik:GridViewComboBoxColumn Header="Shipper Name" DataMemberBinding="{Binding ShipperId}" |
SelectedValueMemberPath="Id" DisplayMemberPath="Name" |
ItemsSourceBinding="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=my:BerthingSlotView, AncestorLevel=1}, Path=ViewModel.Shippers}" /> |
</telerik:RadGridView.Columns> |
</telerik:RadGridView> |
alternatively we tried to set some stuff in the code behind:
<telerik:GridViewComboBoxColumn Header="Shipper Name" DataMemberBinding="{Binding ShipperId}" |
SelectedValueMemberPath="Id" DisplayMemberPath="Name" |
Initialized="ShipperComboBox_Initialized"/> |
private void ShipperComboBox_Initialized(object sender, EventArgs e) |
{ |
var cbx = sender as GridViewComboBoxColumn; |
cbx.ItemsSourceBinding = new Binding { Source = this.ViewModel, Path = new PropertyPath("Shippers") }; |
} |
Any help would be much appreciated to solve the issues with Grouping and the Filter window....
Many Thanks in Advance
M.
16 Answers, 1 is accepted
0

M
Top achievements
Rank 1
answered on 16 Jun 2010, 02:06 PM
Anyone?! Please help...
0
Hello M,
Regarding the filtering problem with the combo column - please have a look at my blog post. It provides a descent solution.
About the grouping problem - I need a few more hours to investigate the problem. I am leaving the thread open and will keep you posted about my findings. I will try to prepare a small app according to your scenario and see what is wrong.
Sincerely yours,
Pavel Pavlov
the Telerik team
Regarding the filtering problem with the combo column - please have a look at my blog post. It provides a descent solution.
About the grouping problem - I need a few more hours to investigate the problem. I am leaving the thread open and will keep you posted about my findings. I will try to prepare a small app according to your scenario and see what is wrong.
Sincerely yours,
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
0
Hi M,
About the grouping related problem - can you please try using the ItemsSource property of the ComboBox instead of the ItemsSourceBinding and let me know if that does not help.
Regards,
Pavel Pavlov
the Telerik team
About the grouping related problem - can you please try using the ItemsSource property of the ComboBox instead of the ItemsSourceBinding and let me know if that does not help.
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
0

M
Top achievements
Rank 1
answered on 18 Jun 2010, 04:08 PM
Hi Pavel,
first of all many thanks for your help - very much appreciated.....
Filter issue:
After your first answer I got cracking with your recommended filter solution.... and I got it working, but it has some quirks, where it doesn't reset the filter sometimes.... is there a way to get some of the source code that you guys use for the orginal filter box... instead of us going of and starting to do a lot of detective work to build a similarly behaving control. Also, how do I convince the custom filter control to use the same theme as the main app / grid?
Grouping:
Now to the grouping... I changed the GridViewComboBoxColumn so that it uses the ItemSource now, but the grouping still doesn't work - the SelectedValueMemberPath is still displayed instead of the DisplayMemberPath.... I checked this also for other columns just in case I am doing something wrong, but no luck.....
Looking forward to hear from you again....
Best Regards
M.
first of all many thanks for your help - very much appreciated.....
Filter issue:
After your first answer I got cracking with your recommended filter solution.... and I got it working, but it has some quirks, where it doesn't reset the filter sometimes.... is there a way to get some of the source code that you guys use for the orginal filter box... instead of us going of and starting to do a lot of detective work to build a similarly behaving control. Also, how do I convince the custom filter control to use the same theme as the main app / grid?
Grouping:
Now to the grouping... I changed the GridViewComboBoxColumn so that it uses the ItemSource now, but the grouping still doesn't work - the SelectedValueMemberPath is still displayed instead of the DisplayMemberPath.... I checked this also for other columns just in case I am doing something wrong, but no luck.....
Looking forward to hear from you again....
Best Regards
M.
0

M
Top achievements
Rank 1
answered on 18 Jun 2010, 04:36 PM
Pavel,
just an addition to my previous post with regards of the filter issues.... I checked in your solution again (the one from the blog) and it is having the same problem.... when you select Italy and you close the filter window by navigating away from it and you open it again you can't bring back the other values anymore, i.e. show France and Germany again in the grid..... the compositeFilterDiscriptor is convinced it is not set anymore.... so it seemed it forgot about the previous filter....
Any suggestions?
Regards
M.
just an addition to my previous post with regards of the filter issues.... I checked in your solution again (the one from the blog) and it is having the same problem.... when you select Italy and you close the filter window by navigating away from it and you open it again you can't bring back the other values anymore, i.e. show France and Germany again in the grid..... the compositeFilterDiscriptor is convinced it is not set anymore.... so it seemed it forgot about the previous filter....
Any suggestions?
Regards
M.
0
Hello M,
Thank you for sharing this info . I have identified the problem in my code and here is the solution :
Please update the Prepare method way:
the new part is added at the beggining of the method :
Greetings,
Pavel Pavlov
the Telerik team
Thank you for sharing this info . I have identified the problem in my code and here is the solution :
Please update the Prepare method way:
public
void
Prepare(Telerik.Windows.Controls.GridViewBoundColumnBase column)
{
if
(
this
.compositeFilterDescriptor !=
null
&&
this
.column.DataControl.FilterDescriptors.Contains(
this
.compositeFilterDescriptor))
return
;
this
.compositeFilterDescriptor=
new
CompositeFilterDescriptor() { LogicalOperator = FilterCompositionLogicalOperator.Or };
this
.column = column
as
GridViewComboBoxColumn;
this
.listBoxDistinctValues.ItemsSource =
this
.column.ItemsSource;
this
.listBoxDistinctValues.DisplayMemberPath =
this
.column.DisplayMemberPath;
this
.column.DataControl.FilterDescriptors.Add(compositeFilterDescriptor);
}
the new part is added at the beggining of the method :
if
(
this
.compositeFilterDescriptor !=
null
&&
this
.column.DataControl.FilterDescriptors.Contains(
this
.compositeFilterDescriptor))
return
;
Greetings,
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
0

M
Top achievements
Rank 1
answered on 23 Jun 2010, 02:27 PM
Hi Pavel,
thanks for your continuous help - much appreciated....
I helped myself in the meantime using reflection (EffectiveFilteringControl), but I will switch to your proposed solution.....
Do you have any updates on the Grouping problem....? We had a presentation to the business yesterday and they were not very impressed - to say the least..... is it somehow possible to escalate this issue?
Many Thanks in advance.....
M.
thanks for your continuous help - much appreciated....
I helped myself in the meantime using reflection (EffectiveFilteringControl), but I will switch to your proposed solution.....
Do you have any updates on the Grouping problem....? We had a presentation to the business yesterday and they were not very impressed - to say the least..... is it somehow possible to escalate this issue?
Many Thanks in advance.....
M.
0
Hello M,
Regarding the grouping problem -
I will gladly help you on that but I am absolutely unable to reproduce the issue here.
Please have a look at the application attached - it has both the issues solved.
Regards,
Pavel Pavlov
the Telerik team
Regarding the grouping problem -
I will gladly help you on that but I am absolutely unable to reproduce the issue here.
Please have a look at the application attached - it has both the issues solved.
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
0

M
Top achievements
Rank 1
answered on 28 Jun 2010, 06:53 PM
Hi Pavel,
many many thanks for your help....
we managed to track down the issue:
We had the same field bound as GridViewDataColumn for calculations (so one field bound to GridViewDataColumn and the same again bound to GridViewComboBoxColumn) - Now, when grouping, the Grid seems to do FirstOrDefault behind the scenes and it was finding the GridViewDataColumn first - therefore it was displaying its values rather than the one from the GridViewComboBoxColumn.... a bit annoying if you don't know that, since I was dragging and dropping the other column.....
Now there is one issue remaining:
We have an GridViewImageColumn that is bound to a converter. So for each integer value for the column the converter displays an image.... unfortunately when Grouping is applied it shows the path to the image (see Screenshot). Is there a way to make grouping show the actual picture?
Many Thanks in advance
Kind Regards
M.
many many thanks for your help....
we managed to track down the issue:
We had the same field bound as GridViewDataColumn for calculations (so one field bound to GridViewDataColumn and the same again bound to GridViewComboBoxColumn) - Now, when grouping, the Grid seems to do FirstOrDefault behind the scenes and it was finding the GridViewDataColumn first - therefore it was displaying its values rather than the one from the GridViewComboBoxColumn.... a bit annoying if you don't know that, since I was dragging and dropping the other column.....
Now there is one issue remaining:
We have an GridViewImageColumn that is bound to a converter. So for each integer value for the column the converter displays an image.... unfortunately when Grouping is applied it shows the path to the image (see Screenshot). Is there a way to make grouping show the actual picture?
Many Thanks in advance
Kind Regards
M.
0
Hi M,
It is great to hear that you have isolated the issue with grouping. It will be helpful for us to have this situation in mind for the future.
Regarding the problem with grouping on image column :
The solution here would be :
Use the GroupHeaderTemplate property of RadGridView. It is a DataTemplate , sou you can place an Image control inside and bind its source to the Header property .
In case the Image does not recognize the string you may need to add a IValueConverter to the Binding.
Regards,
Pavel Pavlov
the Telerik team
It is great to hear that you have isolated the issue with grouping. It will be helpful for us to have this situation in mind for the future.
Regarding the problem with grouping on image column :
The solution here would be :
Use the GroupHeaderTemplate property of RadGridView. It is a DataTemplate , sou you can place an Image control inside and bind its source to the Header property .
<DataTemplate x:Key=
"MyGroupHeaderTemplate"
>
<Image Source=
"{Binding Header}"
/>
</DataTemplate>
In case the Image does not recognize the string you may need to add a IValueConverter to the Binding.
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
0

M
Top achievements
Rank 1
answered on 05 Jul 2010, 05:16 PM
Pavel,
thanks once again for your help - I integrated the DataTemplate like you suggested and grouping is working now as expected....
Unfortunately, we still have an issue with the custom filter we implemented according to your sample earlier in this thread:
We disable functionality on the screen depending on whether Grouping or Filtering is active. For that we have wired up the "Filtered" and / or "Filtering" event of the RadGridView.
Unfortunately this event is not fired for our custom filters. Can you give us some advise on how we integrate this and / or what we have to amend within the filter, so it fires the Filtering / Filtered of the RadGridView events accordingly?!
Many Thanks in advance
M.
thanks once again for your help - I integrated the DataTemplate like you suggested and grouping is working now as expected....
Unfortunately, we still have an issue with the custom filter we implemented according to your sample earlier in this thread:
We disable functionality on the screen depending on whether Grouping or Filtering is active. For that we have wired up the "Filtered" and / or "Filtering" event of the RadGridView.
Unfortunately this event is not fired for our custom filters. Can you give us some advise on how we integrate this and / or what we have to amend within the filter, so it fires the Filtering / Filtered of the RadGridView events accordingly?!
Many Thanks in advance
M.
0
Hi,
Vlad
the Telerik team
You do not need these events in case of your own custom filters since you know (and decide) when the grid will be filtered.
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

M
Top achievements
Rank 1
answered on 06 Jul 2010, 09:38 AM
Vlad,
apologies for my ignorance, but I really want to have only one central location in my view-codebehind from where I can evaluate the GridViewFilteringEventArgs (which I need!).
I would be really grateful if you could give me a more exhaustive answer than the one you given me.... i.e. is there a way to hook the Custom Filter to the Filtering / Filtered event or not - OR alternatively how I obtain from within the custom filter the GridViewFilteringEventArgs....
Many Thanks in advance....
Kind Regards
M.
apologies for my ignorance, but I really want to have only one central location in my view-codebehind from where I can evaluate the GridViewFilteringEventArgs (which I need!).
I would be really grateful if you could give me a more exhaustive answer than the one you given me.... i.e. is there a way to hook the Custom Filter to the Filtering / Filtered event or not - OR alternatively how I obtain from within the custom filter the GridViewFilteringEventArgs....
Many Thanks in advance....
Kind Regards
M.
0
Hi,
Vlad
the Telerik team
When you have custom filtering you add filter descriptors to the grid from your code - you do not need these events since they will point to exactly the same filter descriptors added by you.
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

Ubaldo
Top achievements
Rank 1
answered on 14 Jan 2011, 03:49 PM
Hi Pavel, I'm facing the challenge of implementing a working filtering tool for a ComboBox column too..
I've followed your great solution, and I've made some changes in order to resolve these issues:
1) working even when the ItemsSource of the combo is not an object list, but data coming from ADO Dataset (so a datatable) (I'm a little bit old style, I know... but for the moment I've too much new things to learn! :-))
2) working even when the lookup table has a string key instead of the usual numeric one
3) localization
4) add a Remove Filter button
5) add a Close button (NOT YET RESOLVED, SEE AT THE END OF THE MESSAGE)
Here the changed code for the SelectionChanged method and the xaml for the USerControl
Now I would like to close the filter box clicking on the little X button (cmdClose). I know it will be a very simple thing, but as I'm a real beginner with WPF, I can't figure out how to achieve the goal.
TIA
Ubaldo
I've followed your great solution, and I've made some changes in order to resolve these issues:
1) working even when the ItemsSource of the combo is not an object list, but data coming from ADO Dataset (so a datatable) (I'm a little bit old style, I know... but for the moment I've too much new things to learn! :-))
2) working even when the lookup table has a string key instead of the usual numeric one
3) localization
4) add a Remove Filter button
5) add a Close button (NOT YET RESOLVED, SEE AT THE END OF THE MESSAGE)
Here the changed code for the SelectionChanged method and the xaml for the USerControl
public
ComboColumnFilteringControl()
{
InitializeComponent();
this
.lblHeader.Content = LocalizationManager.GetString(
"GridViewFilterComboColumnHeader"
);
this
.cmdClear.Content = LocalizationManager.GetString(
"GridViewClearFilter"
);
}
private void listBoxDistinctValues_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
compositeFilterDescriptor.FilterDescriptors.Clear();
PropertyInfo propertyInfo;
object itemValue;
foreach (var item in this.listBoxDistinctValues.SelectedItems)
{
if (item.
GetType
() == typeof(System.Data.DataRowView))
{
System.Data.DataRowView rw = (System.Data.DataRowView)item;
propertyInfo = rw.Row.
GetType
().GetProperty((this.column).SelectedValueMemberPath);
itemValue = propertyInfo.GetValue(rw.Row, null);
}
else
{
propertyInfo = item.
GetType
().GetProperty((this.column).SelectedValueMemberPath);
itemValue = propertyInfo.GetValue(item, null);
}
FilterDescriptor fd = new FilterDescriptor(this.column.DataMemberBinding.Path.Path, FilterOperator.IsEqualTo, itemValue);
fd.MemberType = itemValue.
GetType
();
compositeFilterDescriptor.FilterDescriptors.Add(fd);
}
if (this.compositeFilterDescriptor.FilterDescriptors.Count > 0)
this.SetValue(IsActiveProperty, true);
else
this.SetValue(IsActiveProperty, false);
}
private void cmdClear_Click(object sender, RoutedEventArgs e)
{
this.listBoxDistinctValues.SelectedItems.Clear();
compositeFilterDescriptor.FilterDescriptors.Clear();
}
<
Grid.RowDefinitions
>
<
RowDefinition
/>
<
RowDefinition
/>
<
RowDefinition
/>
<
RowDefinition
/>
</
Grid.RowDefinitions
>
<
Button
Name
=
"cmdClose"
Content
=
"X"
Grid.Row
=
"0"
HorizontalAlignment
=
"Right"
Margin
=
"2"
Padding
=
"1"
Height
=
"20"
Width
=
"20"
Click
=
"cmdClose_Click"
/>
<
Label
Grid.Row
=
"1"
Name
=
"lblHeader"
Content
=
"Select countries:"
/>
<
ListBox
Grid.Row
=
"2"
x:Name
=
"listBoxDistinctValues"
SelectionChanged
=
"listBoxDistinctValues_SelectionChanged"
SelectionMode
=
"Multiple"
Height
=
"Auto"
MaxHeight
=
"300"
Width
=
"Auto"
MinWidth
=
"120"
MaxWidth
=
"250"
>
</
ListBox
>
<
Button
Name
=
"cmdClear"
Content
=
"Clear filter"
Grid.Row
=
"3"
HorizontalAlignment
=
"Right"
Margin
=
"5"
Padding
=
"3"
Click
=
"cmdClear_Click"
/>
TIA
Ubaldo
0
Hi Ubaldo,
You can just place a button in the template of the filtering control and within the click handler do something like :
I believe this would do the trick.
Best wishes,
Pavel Pavlov
the Telerik team
You can just place a button in the template of the filtering control and within the click handler do something like :
private
void
Button_Click(
object
sender, RoutedEventArgs e)
{
var popup =
this
.ParentOfType<Popup>();
popup.IsOpen =
false
;
}
I believe this would do the trick.
Best wishes,
Pavel Pavlov
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>