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

GroupDescriptor and async data sources (Q3, 2011)

1 Answer 27 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Mike
Top achievements
Rank 1
Mike asked on 05 Dec 2011, 06:59 AM
Hi there,

When using a basic RIA Services domain data source initialised via XAML, the Q3 2011 version of the GroupDescriptor implementation is throwing an exception:

<UserControl x:Class="RadControlsGroupDescriptorAsync.MainPage"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
            xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
            xmlns:riaControls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.DomainServices"
            xmlns:Web="clr-namespace:RadControlsGroupDescriptorAsync.Web"
            mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480">
    <Grid x:Name="LayoutRoot">
        <riaControls:DomainDataSource AutoLoad="True"                                              
                                              Name="FooBarDomainDataSource"
                                              QueryName="GetFooBars" >
            <riaControls:DomainDataSource.DomainContext>
                <Web:FooBarContext />
            </riaControls:DomainDataSource.DomainContext>
        </riaControls:DomainDataSource>
 
        <telerik:RadGridView AutoGenerateColumns="True" Width="500" Height="400"
                      ItemsSource="{Binding ElementName=FooBarDomainDataSource, Path=Data}"
                      Name="FooBarDataGrid"
                      IsReadOnly="False"
                      ShowGroupPanel="False"
                      IsBusy="{Binding ElementName=FooBarDomainDataSource, Path=IsBusy}"
                      AutoExpandGroups="True">
            <telerik:RadGridView.GroupDescriptors>
                <telerik:GroupDescriptor Member="Foo"/>
            </telerik:RadGridView.GroupDescriptors>
        </telerik:RadGridView>
 
    </Grid>
</UserControl>

I'm getting "A first chance exception of type 'System.NullReferenceException' occurred in Telerik.Windows.Data", whilst it worked fine with a previous release. I got it working by binding the data once the async operation had completed, but I would prefer just to have it in the XAML like it worked before.

Workaround:

Remove GroupDescriptor XAML, and instead add handler for datasource "LoadedData" event. Manually add the GroupDescriptor in the codebehind:

private void FooBarDomainDataSource_LoadedData(object sender, LoadedDataEventArgs e)
        {
                FooBarDataGrid.GroupDescriptors.Add(new GroupDescriptor { Member = "Foo", SortDirection = ListSortDirection.Ascending });
        }

I have a working solution available for download here: RadControlsGroupDescriptorAsync.zip

1 Answer, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 08 Dec 2011, 10:14 AM
Hello,

Other possible solution will be to use RadDomainDataSource.

Kind regards,
Vlad
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
GridView
Asked by
Mike
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Share this question
or