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

RadDomainDataSource problem with DataPager

4 Answers 97 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Chris Thierry
Top achievements
Rank 1
Chris Thierry asked on 19 Jan 2011, 11:30 PM
Hi, I'm using the new RadDomainDataSource, I have a problem with the DataPager, the first time the datapager shows me Page zero, when I click next page, it shows me page 1 wich is the same page as page 0!, is there any problem?, I send you the code:

In my XAML file:
<telerik:RadGridView
            x:Name="rgvEmployeeSelect"            
            Grid.Column="0"
            Grid.Row="1" 
            Margin="10,0,10,0"
            Cursor="Hand"
            AutoGenerateColumns="False" 
            AlternateRowBackground="{StaticResource GridRowBackgroundColorBrush}"
            AlternationCount="2"                        
            CanUserFreezeColumns="False"                        
            CanUserDeleteRows="False" 
            CanUserInsertRows="False"   
            ColumnWidth="*"
            IsReadOnly="True"
            ShowGroupPanel="False"
            RowIndicatorVisibility="Collapsed"             
            HorizontalAlignment="Stretch" 
            VerticalAlignment="Stretch"         
            ScrollViewer.VerticalScrollBarVisibility="Auto"
            ItemsSource="{Binding DataView, ElementName=ddsEmployeeSelectUC}" />
  
        <telerik:RadDataPager 
            x:Name="dpgEmployeeSelect"            
            Grid.Column="0"
            Grid.Row="2"             
            PageSize="50"
            DisplayMode="FirstLastPreviousNext"             
            VerticalAlignment="Center"
            HorizontalAlignment="Stretch"
            Margin="10,0,10,0"
            Source="{Binding DataView, ElementName=ddsEmployeeSelectUC}" />

In my cs code:

RadDomainDataSource dds = new RadDomainDataSource();
  
dds.PageSize = 50;
dds.Name = "ddsEmployeeSelectUC";
dds.QueryName = "GetEmployee2";
          
dds.QueryParameters.Add(new QueryParameter { ParameterName = "department", Value = Entity.Department });
dds.QueryParameters.Add(new QueryParameter { ParameterName = "employeeID", Value = Entity.Employee });
  
dds.DomainContext = this.context;
dds.Load();
this.Resources.Add("ddsEmployeeSelectUC", dds);

If I chage to DomainDataSource instead of RadDomainDataSource, is working ok. Any idea?
Thank you.

4 Answers, 1 is accepted

Sort by
0
Chris Thierry
Top achievements
Rank 1
answered on 20 Jan 2011, 06:22 PM
I found the problem, this is the order in the cs code:

RadDomainDataSource dds = new RadDomainDataSource(); 
    
dds.QueryName = "GetEmployee2";          
dds.QueryParameters.Add(new QueryParameter { ParameterName = "department", Value = Entity.Department }); 
dds.QueryParameters.Add(new QueryParameter { ParameterName = "employeeID", Value = Entity.Employee }); 
  
dds.DomainContext = this.context; 
dds.Name = "ddsEmployeeSelectUC";  
dds.PageSize = 50; 
  
dds.Load(); 
this.Resources.Add("ddsEmployeeSelectUC", dds);

PageSize should be after DomainContext.
Thanks
0
Accepted
Rossen Hristov
Telerik team
answered on 21 Jan 2011, 10:24 AM
Hi Chris Thierry,

It is not very correct to instantiate an an user control in code behind and use it there. When RadDomainDataSource is defined in XAML two methods on it are called by the XAML parser -- BeginInit and EndInit. When you instantiate it in code-behind this methods are not called and maybe that is why it is behaving weird.

Anyway, for cases like yours we have provided the view that RadDomainDataSource uses internally, so you can use it in such code-behind and/or MVVM scenarios. This blog describes how to use the QueryableDomainServiceCollectionView<TEntity> in an MVVM manner to gain full control over what is going on. The blog contains a comprehensive sample solution that wraps a collection view in a view model and does all kinds of things to it.

I have also prepared a sample project based on your source code, but I have replaced RadDomainDataSource with the collection view. My sample project does not bind stuff through view models like the blog post does just for the sake of simplicity.

I hope this helps. Let me know if there are problems.

Regards,
Ross
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
Chris Thierry
Top achievements
Rank 1
answered on 21 Jan 2011, 04:50 PM
Thank you!
0
Rossen Hristov
Telerik team
answered on 21 Jan 2011, 04:57 PM
Hi Chris Thierry,

By the way, it was exactly what I thought. If you place BeginInit() after you create it and then EndInit just before you call Load it seems to work correctly.

But use the QueryableDomainServiceCollectionView<T> in such scenarios since it is not an UIElement.

Best wishes,
Ross
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
Chris Thierry
Top achievements
Rank 1
Answers by
Chris Thierry
Top achievements
Rank 1
Rossen Hristov
Telerik team
Share this question
or