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

3 posts, 0 answers
  1. Piet van Bruggen
    Piet van Bruggen avatar
    4 posts
    Member since:
    Dec 2009

    Posted 29 Sep 2011 Link to this post


    I found an issue with the RadDomainDataSource; if i use the following code:
    <telerik:RadDomainDataSource x:Name="grdDataSource" PageSize="20" AutoLoad="True"
            <telerik:SortDescriptor Member="Id" SortDirection="Ascending"/>
    <telerik:RadGridView x:Name="grdData"
        SelectionMode="Single" IsReadOnly="True"  VerticalAlignment="Top"
        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.


  2. Rossen Hristov
    Rossen Hristov avatar
    2478 posts

    Posted 30 Sep 2011 Link to this post

    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.

    the Telerik team

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

  3. Piet van Bruggen
    Piet van Bruggen avatar
    4 posts
    Member since:
    Dec 2009

    Posted 11 Oct 2011 Link to this post

    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...


Back to Top