I am a beginner and I have a problem with RadgridView control. I have two separate RadGridView control (master-detail). Namely, when the master table is positioned on the record that has no children, the detail still shows data from previous records.
I use VS2010 RC and Trial Teleric controls for WPF.
Operating system: Windows 7 Ultimate Edition
4 Answers, 1 is accepted
Could you please give us more information about your application? It is hard to determine what the problem is by looking at the current information. It will be great if you could send us your application.
Here are some questions that will help us determine the problem: What kind of data are the two grid bound to? How is the details grid populated with data?
Kind regards,
Milan
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.

Thanks for the fast response. Here are some more detailed explanation:
I use the Entity Framework with SQL 2008 Express database.
the first table: SchoolTypes (SchoolTypeID, SchoolTypeName, PK: SchoolTypeId)
second table: Schools (SchoolID, SchoolName, SchoolTypeID (foreign key) PK: SchoolID, FC: SchoolTypeID
On the screen I have 2 RadGridView controls whose Itemsources are bound to corresponding CollectionViewSource (classical master-detail scenario).
The problem is as follows:
When the individual record from the master table(SchoolType) has child records in detail table (Schools), everything works properly, ie. second controls is showing appropriate records. The problem arises when record from the first table does not have appropriate children's records. In this case, second control, instead of being empty, it shows data related to the previous record that was selected in the first control.
Here's the XAML:
<Window x:Class="DSBag.w_telerik" |
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
Title="w_telerik" Height="550" Width="529" xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" mc:Ignorable="d" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:my="clr-namespace:DSBag" Loaded="Window_Loaded"> |
<Window.Resources> |
<CollectionViewSource x:Key="schoolTypesViewSource" d:DesignSource="{d:DesignInstance my:SchoolType, CreateList=True}" /> |
<CollectionViewSource x:Key="schoolTypesSchoolsViewSource" Source="{Binding Path=Schools, Source={StaticResource schoolTypesViewSource}}" /> |
</Window.Resources> |
<Grid DataContext="{StaticResource schoolTypesViewSource}"> |
<telerik:RadGridView Height="153" HorizontalAlignment="Left" ItemsSource="{Binding}" Margin="12,12,0,0" Name="schoolTypesRadGridView" VerticalAlignment="Top" Width="482" /> |
<telerik:RadGridView Height="268" HorizontalAlignment="Left" ItemsSource="{Binding Source={StaticResource schoolTypesSchoolsViewSource}}" Margin="12,216,0,0" Name="schoolsRadGridView" VerticalAlignment="Top" Width="482" /> |
</Grid> |
</Window> |
private System.Data.Objects.ObjectQuery<SchoolType> GetSchoolTypesQuery(DSEntities dSEntities) |
{ |
// Auto generated code |
System.Data.Objects.ObjectQuery<DSBag.SchoolType> schoolTypesQuery = dSEntities.SchoolTypes; |
// Update the query to include Schools data in SchoolTypes. You can modify this code as needed. |
schoolTypesQuery = schoolTypesQuery.Include("Schools"); |
// Returns an ObjectQuery. |
return schoolTypesQuery; |
} |
private void Window_Loaded(object sender, RoutedEventArgs e) |
{ |
DSBag.DSEntities dSEntities = new DSBag.DSEntities(); |
// Load data into SchoolTypes. You can modify this code as needed. |
System.Windows.Data.CollectionViewSource schoolTypesViewSource = ((System.Windows.Data.CollectionViewSource)(this.FindResource("schoolTypesViewSource"))); |
System.Data.Objects.ObjectQuery<DSBag.SchoolType> schoolTypesQuery = this.GetSchoolTypesQuery(dSEntities); |
schoolTypesViewSource.Source = schoolTypesQuery.Execute(System.Data.Objects.MergeOption.AppendOnly); |
} |
I have investigated the problem and it turned out that there is a bug in RadGridView that is manifested when RadGridView is bound to an empty ICollectionView. We have logged the issue as PITS item and you will be able to track the status of this bug.
For the time being I can offer you a workaround that fixes the issue - it is not as elegant as the original code but it should work.
private
void
Window_Loaded(
object
sender, RoutedEventArgs e)
{
DSBag.DSEntities dSEntities =
new
DSBag.DSEntities();
// Load data into SchoolTypes. You can modify this code as needed.
System.Windows.Data.CollectionViewSource schoolTypesViewSource = ((System.Windows.Data.CollectionViewSource)(
this
.FindResource(
"schoolTypesViewSource"
)));
System.Data.Objects.ObjectQuery<DSBag.SchoolType> schoolTypesQuery =
this
.GetSchoolTypesQuery(dSEntities);
schoolTypesViewSource.Source = schoolTypesQuery.Execute(System.Data.Objects.MergeOption.AppendOnly);
// CHANGE
// subscribe to CurrentChanged
schoolTypesViewSource.View.CurrentChanged +=
new
System.EventHandler(View_CurrentChanged);
}
void
View_CurrentChanged(
object
sender, System.EventArgs e)
{
var schoolTypesViewSource = ((System.Windows.Data.CollectionViewSource)(
this
.FindResource(
"schoolTypesViewSource"
)));
if
(schoolTypesViewSource !=
null
&& schoolTypesViewSource.View !=
null
)
{
// get the current item of master grid
var current = (SchoolTypes)schoolTypesViewSource.View.CurrentItem;
if
(current ==
null
|| current.Schools.Count <= 0)
// clear child grid if no schools are associated
this
.schoolsRadGridView.ItemsSource =
null
;
else
this
.schoolsRadGridView.ItemsSource = current.Schools;
}
}
Also you should remove the ItemsSource binding for schooldRadGridView that is defined in XAML. Finally, you should set IsSynchronizedWithCurrentItem to true for schoolTypesRadGridView. IsSynchronizedWithCurrentItem was introduced a couple of weeks ago and is available in our latest Internal Build.
Thank you for reporting this issue - I have updated your Telerik points. We will try to fix the related bug as soon as possible. Sorry for the inconvenience.
Greetings,Milan
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.
