Load(true) doesn't load

8 posts, 0 answers
  1. Masoud
    Masoud avatar
    61 posts
    Member since:
    Aug 2011

    Posted 31 Jan 2012 Link to this post

    Hi there,

    I am having a strange behavior with calling QDSCV from code behind.  I will try and explaing the scenario using the order/customer analogy with the exception that the orders can be customer-less.

    I have a RadWindow, OrderView, where I can edit an order, thereby setting, changing and removing the assigned customer.  When the user wants to assign a customer, they click a button and a RadWindow, CustomerView is started.  

    CustomerView has the following markup

    <Controls:RadGridView x:Name="CustomerGrid" SelectionMode="Extended" SelectedItem="{Binding Path=Current, Mode=TwoWay}" AutoGenerateColumns="False" ShowColumnHeaders="True" ShowGroupPanel="False" CanUserDeleteRows="False" CanUserFreezeColumns="False" CanUserInsertRows="False" CanUserReorderColumns="True" CanUserResizeColumns="True" BorderBrush="Black" IsFilteringAllowed="False" FontSize="16" RowHeight="28" HorizontalGridLinesBrush="#A6000000" RowDetailsVisibilityMode="VisibleWhenSelected" RowIndicatorVisibility="Collapsed" VerticalGridLinesBrush="#A6000000" Margin="4" TabNavigation="Cycle" Height="420" />

    In CodeBehind I am instantiating the QDSCV as follows:
    var itemsSource = new QueryableDomainServiceCollectionView<KundeEntity>(SimpleServiceLocator.Instance.Get<IBasisBauemeModel>().Context, SimpleServiceLocator.Instance.Get<IBasisBauemeModel>().Context.GetKundenQuery());
    itemsSource.LoadingData += KundeDataSourceLoadingData;
    itemsSource.AutoLoad = true;
    itemsSource.PageSize = 10;
    KundeGrid.ItemsSource = itemsSource;
    KundePager.Source = itemsSource;
    itemsSource.Load(true);

    In order to assure the "fresh" data is loaded, I subscribe to LoadingData and set LoadBehavior 

    private void CustomerDataSourceLoadingData(object sender, Telerik.Windows.Controls.DomainServices.LoadingDataEventArgs e)
    {
        e.LoadBehavior = LoadBehavior.RefreshCurrent;
    }


    All works fine except for the following scenario:
    - In OrderView I unassign a customer from the order.  The Entity customer is then removed from the order.
    - I try to assign another custome to the order and start CustomerView.  No call to the server is made. Fiddler shows no network activity.  - CustomerDataSourceLoadingData is not hit when the customer has been unassigned from the order.  It is only hit if no operations have been conducted.

    I would really appreciate your help on this.  Doing data-retrival the "Telerik-Way" was promising to be great until I hit this issue!!!

    Greetings

  2. Rossen Hristov
    Admin
    Rossen Hristov avatar
    2478 posts

    Posted 01 Feb 2012 Link to this post

    Hello,

    From your description, it seems that you cannot load because the underlying domain context is dirty, i.e. it has changes. The QDSCV will refuse to load new data when it HasChanges. In order to be able to load new data you will have to either SubmitChanges or RejectChanges. This is the way we have designed our collection for numerous reasons.

    Also, you don't have to use the Load(true) overload of the method. When AutoLoad is set to true, when you submit or reject the changes, the view will automatically refresh from the server.

    I hope this helps.

    Regards,
    Ross
    the Telerik team

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

  3. DevCraft banner
  4. Masoud
    Masoud avatar
    61 posts
    Member since:
    Aug 2011

    Posted 01 Feb 2012 Link to this post

    Dear Ross,

    thank you for your reply and the explanation!

    How would you suggest solving the issue at hand here?  The user will need to be able to attach a customer to an order.  In order to do this, I need to show the user the available customers (filtered according to certain criteria).  I cannot use a different domain context for this purpose (I will not be able to attach customer from domain context A to order from domain context B), so I am bound to using the "dirty" domain context.  What works at the moment is using the Load method of the domain context to directly load the customers.   Using Load of domain context, however, deprives me of all the wonders of Rad controls (filtering, paging, etc), so that is ruled out.  

    Would really appreciate any suggestion you could make!

    Best regards



  5. Rossen Hristov
    Admin
    Rossen Hristov avatar
    2478 posts

    Posted 01 Feb 2012 Link to this post

    Hello,

    Unfortunately, I am afraid that I cannot think of a nice workaround for this particular case. 

    If you use the same domain context to load the customers "by hand" you can still have filtering and sorting by using our extension methods located in the assembly Telerik.Windows.Controls.DomainServices in the class EntityQueryExtensions. Basically these methods will allow you translate "our" FilterDescriptors, SortDescriptors, etc. to the EntityQuery language. Once you have an EntityQuery which is configured according to the FilterDescriptors and so on, you can load this query directly with the domain context.

    I am not sure whether this is a viable option, but I am afraid that this is the only thing that I can think of.

    Greetings,
    Ross
    the Telerik team

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

  6. Masoud
    Masoud avatar
    61 posts
    Member since:
    Aug 2011

    Posted 01 Feb 2012 Link to this post

    Dear Ross,

    could you please provide an example using the EntityQueryExtentions with a RadGridView and a RadDataPager ? 

    Greetings
  7. Masoud
    Masoud avatar
    61 posts
    Member since:
    Aug 2011

    Posted 01 Feb 2012 Link to this post

    Dear Ross,

    I have figured out how to bind the Grid.  could you please provide information on binding the RadDataPager?

    Greetings
  8. Rossen Hristov
    Admin
    Rossen Hristov avatar
    2478 posts

    Posted 01 Feb 2012 Link to this post

    Hello,

    The pager does not have descriptors. It has PageIndex and PageSize. These two things do the Skip and Take on the entity query.

    You can use the pager in unbound mode (described in the docs) and then take its page index and page size, do the math and generate a Skip and Take method calls and append them on the entity query. In case this is what you are asking for.

    All the best,
    Ross
    the Telerik team

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

  9. Anand
    Anand avatar
    1 posts
    Member since:
    Mar 2012

    Posted 21 Mar 2012 Link to this post

    [Reload the data every time (force a refresh) using the same context instance and queryabledomainserviceview object]
    Hi,
    We have a similar issue. We are trying to use a singleton context throughout the application. When loading the data using this singleton context we used singleton Queryabledomainservicecollectionviews as well. The problem is - When we invoke queryabledomainservicecollectionview. Load [both with and without forced loading = true) the data is loaded the first time and we get the "LoadedData" event. But on successive runs (2nd time "load" invocation and beyond) the data does not refresh from backend and we do not get the "LoadedData" event to confirm the same.
    We want to reload the data every time (force a refresh) using the same context instance and queryabledomainserviceview object.
    Can someone please suggest how to achieve this?

    thanks
    Anand
Back to Top
DevCraft banner