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

RadGridView with CollectionViewSource

3 Answers 509 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Bradley Schultz
Top achievements
Rank 1
Bradley Schultz asked on 19 Jan 2011, 07:28 PM
I am having two issues with the below user control view that is mostly a RadGridView. The ItemsSource is a CollectionViewSource View. The view is based on an ObservableCollection and filtering is utilized. Everything seems to work for the most part if I host the user control in a regular Microsoft TabControl. If I use a RadTabControl, each tab does not seem to respect the CollectionViewSource.View that it is bound to so on the first tab I might get the data to be expected on the last or vice versa.

EDIT: Just to be clear, each tab item is bound to a different instance of a CollectionViewSource over the same ObservableCollection.

Second, whether I host the control in a TabControl or RadTabControl, if I try to use the UI to group by a column on one tab, the column is grouped on all tabs. If I ungroup a tab, I need to remove the group manually from the other tabs before things return to normal.

Any suggestions for alternatives that might work better together? Why am i getting different results hosting the control in TabControl vs RadTabControl? I tried the telerik QueryableView a bit, but it seems like this is built more for LinqToSQL or ORM.

<

 

 

UserControl x:Class="XXXXXXXXXXX"
xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation
xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="416" d:DesignWidth="736" xmlns:telerik=http://schemas.telerik.com/2008/xaml/presentation
xmlns:Behaviors="XXXXXXXXXXX">
<UserControl.Resources>
<Style x:Key="RowStyle" TargetType="telerik:GridViewRow" >
<Setter Property="FontFamily" Value="Segoe UI" />
<Setter Property="FontSize" Value="11" />
</Style>
<Style x:Key="HeaderStyle" TargetType="telerik:GridViewHeaderRow">
<Setter Property="FontFamily" Value="Segoe UI" />
<Setter Property="FontSize" Value="11" />
<Setter Property="FontWeight" Value="Bold" />
</Style>
</UserControl.Resources>
<Grid>
<Grid.RowDefinitions >
<RowDefinition Height="*"/>
<RowDefinition Height="40"/>
</Grid.RowDefinitions>
<telerik:RadGridView Name="gridv" Grid.Row="0" ItemsSource="{Binding Path=RecordModels.View}" AutoGenerateColumns="False" CanUserResizeColumns="False"
IsFilteringAllowed="False" IsSynchronizedWithCurrentItem="True" Behaviors:MouseDoubleClickEventBehavior.MouseDoubleClickEvent="{Binding DoubleClickEvent}"
RowStyle="{StaticResource RowStyle}" HeaderRowStyle="{StaticResource HeaderStyle}" SelectionUnit="FullRow">
<telerik:RadGridView.Columns>
<telerik:GridViewImageColumn Width="22" Header="" DataMemberBinding="{Binding IsValid}" />
<telerik:GridViewDataColumn Header="MRN" DataMemberBinding="{Binding MRN}" Width="*" />
<telerik:GridViewDataColumn Header="DOS" DataMemberBinding="{Binding DOS}" Width="*" />
<telerik:GridViewDataColumn Header="Description" DataMemberBinding="{Binding Description}" Width="*" />
<telerik:GridViewDataColumn Header="Provider" DataMemberBinding="{Binding ProviderName}" Width="*" />
<telerik:GridViewDataColumn Header="Start" DataMemberBinding="{Binding StartTime}" Width="*" />
<telerik:GridViewDataColumn Header="Stop" DataMemberBinding="{Binding StopTime}" Width="*" />
<telerik:GridViewDataColumn Header="Contents" DataMemberBinding="{Binding Contents}" Width="*" />
<telerik:GridViewColumn Header="" Width="20">
<telerik:GridViewColumn.CellTemplate>
<DataTemplate>
<telerik:RadButton Content="..." />
</DataTemplate>
</telerik:GridViewColumn.CellTemplate>
</telerik:GridViewColumn>
</telerik:RadGridView.Columns>
</telerik:RadGridView>
<StackPanel Grid.Row="1">
<TextBlock Text="{Binding RecordListSummary}" HorizontalAlignment="Left" Margin="5" />
<TextBlock Text="{Binding CurrentItem.MRN,ElementName=gridv}" />
</StackPanel>
</Grid>
</
UserControl>

 

 

 

 

 

3 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 20 Jan 2011, 01:32 PM
Hello,

 If you want to have different "views" for each tab you need to use some collection that will not persists various settings like sorting, grouping, currency. etc. You can use simple IList to achieve your goal. 

Kind regards,
Vlad
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
0
Bradley Schultz
Top achievements
Rank 1
answered on 20 Jan 2011, 06:18 PM
I understand that I can use the IList, etc. but the idea is that I want to take advantage of the ObservableCollection and Filtering so that I don't have to notify the multiple views of changes myself, they are handled automatically.

When you say that the collection persists various settings, how is that relevant. Each tab item has a new'd CollectionViewSource instance. I thought that this is where these things were persisted. Is this somehow linked directly to the ObservableCollection rather than than CollectionViewSource.View? If so, why does the filtering seem to work properly but not the grouping? Is this just functionality that is not yet complete? Are there any other alternatives?
0
Maya
Telerik team
answered on 25 Jan 2011, 02:19 PM
Hello Bradley Schultz,

In order to provide you with an appropriate solution, I would need a bit more information, mainly about the way you create the instances of the CollectionViewSource-s and your ViewModel. May you verify whether you are setting two different instances of the CollectionViewSource-s to the different grids (you may use the Make Object ID functionality of the Visual Studio for example) ?
Still I am sending you the sample project I used in my attempt to reproduce your scenario. Please take a look at it and let me know in case of any misunderstandings.

Best wishes,
Maya
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
Tags
GridView
Asked by
Bradley Schultz
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Bradley Schultz
Top achievements
Rank 1
Maya
Telerik team
Share this question
or