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

RadDomainDataSource does not use PageSize (Take) when initialized from code-behind

2 Answers 61 Views
DomainDataSource
This is a migrated thread and some comments may be shown as answers.
Piet van Bruggen
Top achievements
Rank 1
Piet van Bruggen asked on 29 Sep 2011, 07:01 AM
Hello,

I found an issue with the RadDomainDataSource; if i use the following code:
<telerik:RadDomainDataSource x:Name="grdDataSource" PageSize="20" AutoLoad="True"
                    QueryName="GetCustomers">
    <telerik:RadDomainDataSource.DomainContext>
        <myService:myContext/>
    </telerik:RadDomainDataSource.DomainContext>
    <telerik:RadDomainDataSource.SortDescriptors>
        <telerik:SortDescriptor Member="Id" SortDirection="Ascending"/>
    </telerik:RadDomainDataSource.SortDescriptors>
</telerik:RadDomainDataSource>
<telerik:RadGridView x:Name="grdData"
    SelectionMode="Single" IsReadOnly="True"  VerticalAlignment="Top"
    AutoGenerateColumns="True"                                        
    ItemsSource="{Binding PagedSource, ElementName=grdPager}"
    IsBusy="{Binding IsBusy, ElementName=grdDataSource}" />
<telerik:RadDataPager x:Name="grdPager" PageSize="10"
     Source="{Binding DataView, ElementName=grdDataSource}"
     DisplayMode="FirstLastPreviousNextNumeric, Text"
     IsTotalItemCountFixed="True" />

This works perfectly ok, but if i leave out the QueryName here and set it from code-behind i see in fiddler that it is not using Take anymore on the ria calls. This causes the entire customers list to load and eventually crashes iexplore due to memory issues (> 2GB)

Yesterday i posted this on a forum as well, but for some strange reason i cannot find the posting back so therefore i'm issueing this as a bug right now; you may remove the posting if needed / found.

Regards,

Piet

2 Answers, 1 is accepted

Sort by
0
Rossen Hristov
Telerik team
answered on 30 Sep 2011, 05:54 AM
Hello Piet,

Unfortunately when setting the query name in code behind you will have to assign the page size after you set the query name, since currently order matters. When everything is set in XAML we depend on the ISupportInitialize interface to wait for everything to be set before trying to go to the server. But when the query name is left out there seems to be a problem of some sort which we will investigate. We will do our best to improve this aspect of the control for a future release so that the order and XAML/code-behind will not matter anymore.

I have prepared a sample project which demonstrates one possible approach for setting the query name in code-behind. 

Here is the order in which you have to set the three things in code-behind:

this.customersDataSource.QueryName = "GetCustomers";
this.customersDataSource.PageSize = 20;
this.customersDataSource.AutoLoad = true;

Let me know if this approach will not work in your case and I will try to think of something else.

Regarding the PageSizes. When you have a pager bound to a RDDS you can't have two different page sizes. That is physically and logically impossible. Simply leave the desired PageSize on the RDDS and the pager will automatically pick it up since RDDS.DataView implements the IPagedCollectionView interface. Of course you can define the same PageSize on the pager as well, but that would be redundant. The bottom-line is that you can't have two different page sizes defined on both controls since this does not make any sense at all and only one of them will be used anyway. So please, leave only RDDS.PageSize.

I hope this helps. Let me know if it does not.

Regards,
Ross
the Telerik team

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

0
Piet van Bruggen
Top achievements
Rank 1
answered on 11 Oct 2011, 12:51 PM
Hello Ross,

Sorry for the late reply; i figured out the solution you provided here as well so that will work indeed. However i found it very strange that the order was mandatory; as the AutoLoad was set before already and i don't expect it to be false after setting the queryname...

We will see if the behavior will be changed in future releases, for now this is ok with me...

Regards,

Piet
Tags
DomainDataSource
Asked by
Piet van Bruggen
Top achievements
Rank 1
Answers by
Rossen Hristov
Telerik team
Piet van Bruggen
Top achievements
Rank 1
Share this question
or