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

Cannot Reload Data

11 Answers 277 Views
DomainDataSource
This is a migrated thread and some comments may be shown as answers.
AP
Top achievements
Rank 1
Iron
Iron
Veteran
AP asked on 18 Mar 2011, 05:19 PM
I'm using the RadDomainDataSource to display a summary of data held in several tables on a SQL Server (based on a view).

A RadGridView is then bound to this, and users can click on rows, to see a graphical summary of the selected table.

The definition is:-
<telerik:RadDomainDataSource Height="0" HorizontalAlignment="Left"  Name="radDomainDataSource1" VerticalAlignment="Top" Width="0" QueryName="GetTableSummariesQuery" AutoLoad="True">
            <telerik:RadDomainDataSource.DomainContext>
                <server:CYContext/>
            </telerik:RadDomainDataSource.DomainContext>

Whilst I don't need to keep this up to date in real time, I do neet to be able to allow users to refresh the data, so see if any changes have been made.

I've added a refresh button with the code:-
radDomainDataSource1.Load();

But whilst the gridview shows the busy indicator, and goes through the motions of refreshing, the data doesn't reflect the changes in the view.

Thanks

11 Answers, 1 is accepted

Sort by
0
Accepted
Yavor Georgiev
Telerik team
answered on 21 Mar 2011, 08:32 AM
Hi Andrew,

 The RIA DomainContext caches the entities it has already downloaded from the server and only transports adds or deletes from the server. RadDomainDataSource exposes the LoadingData event. You can handle it like so:
private void OnLoadingData(object sender, LoadingDataEventArgs e)
{
    e.LoadBehavior = LoadBehavior.RefreshCurrent;
}

 This will override the default RIA behavior and replace the already-cached entities with the data coming from the server.

Regards,
Yavor Georgiev
the Telerik team
0
AP
Top achievements
Rank 1
Iron
Iron
Veteran
answered on 21 Mar 2011, 09:36 AM
Thanks, that worked.
0
sebastian
Top achievements
Rank 1
answered on 28 Apr 2011, 11:23 PM
Great! it works for me too but i have always a little problem :

I have two radGrid with two different domaindatasource
when i edit a row in the first radgrid i need to refresh data in the second one.

So i have done : 

private void RadGridTest_RowEditEnded(object sender, Telerik.Windows.Controls.GridViewRowEditEndedEventArgs e)
        {
            if (e.EditOperationType == Telerik.Windows.Controls.GridView.GridViewEditOperationType.Edit)
            {
                RdsSquadre.SubmitChanges();
                RdsSquadra.Load();
            
  
        }
  
private void RdsSquadra_LoadingData(object sender, Telerik.Windows.Controls.DomainServices.LoadingDataEventArgs e)
        {
            e.LoadBehavior = System.ServiceModel.DomainServices.Client.LoadBehavior.RefreshCurrent;
        }

 



But the second grid refresh before Submitchanges have effect so i have to refresh another time to see changes ...

How i can solve this problem?

0
sebastian
Top achievements
Rank 1
answered on 28 Apr 2011, 11:36 PM
Solved !

private void RadGridTest_RowEditEnded(object sender, Telerik.Windows.Controls.GridViewRowEditEndedEventArgs e)
        {
            if (e.EditOperationType == Telerik.Windows.Controls.GridView.GridViewEditOperationType.Edit)
            {
                RdsSquadre.SubmitChanges();
            
  
        }
  
        private void RdsSquadre_LoadedData(object sender, Telerik.Windows.Controls.DomainServices.LoadedDataEventArgs e)
        {
            RdsSquadra.Load();
        }
  
        private void RdsSquadra_LoadingData(object sender, Telerik.Windows.Controls.DomainServices.LoadingDataEventArgs e)
        {
            e.LoadBehavior = System.ServiceModel.DomainServices.Client.LoadBehavior.RefreshCurrent;
        }

It works very nice :)

Thanks
0
Chris Thierry
Top achievements
Rank 1
answered on 30 Jun 2011, 09:04 PM

Hi
this doesn't work for me....

this is my RadDomainDataSource definition:
<telerik:RadDomainDataSource 
    x:Name="RadDomainDataSourceOrgUnit"
    AutoLoad="True"
    QueryName="GetOrganizationUnitQuery"            
    LoadDelay="{Binding Value, ElementName=loadDelay, Converter={StaticResource LoadDelayConverter}}"            
    LoadedData="RadDomainDataSourceOrgUnit_LoadedData"
    LoadingData="RadDomainDataSourceOrgUnit_LoadingData"
    PageSize="25">            
    <telerik:RadDomainDataSource.DomainContext>
        <e:DashboardDomainContext/>
    </telerik:RadDomainDataSource.DomainContext>
    <telerik:RadDomainDataSource.QueryParameters>
        <telerik:QueryParameter ParameterName="subsidiary" Value="{Binding DashboardSubsidiary}" />
    </telerik:RadDomainDataSource.QueryParameters>
</telerik:RadDomainDataSource>

DashboardSubsidiary is a variable defined in my code-behind, in the beginning of my control I'm using :
this.DataContext = this;
so I can capture the value of the variable that I receive as parameter, everything  works ok, I'm using a LoadDelay (I removed the parameter because is not my problem now...) is working ok as well.
The problem is that I need to refresh my RadDomainDataSource, because AutoLoad is True, the first time is ok, but, when I change the paramerter, is not refreshing the grid...

This is the code of the grid:
<telerik:RadGridView
    x:Name="RadGridViewOrgUnit"             
    Grid.Column="0"
    Grid.Row="2" 
    Margin="10,0,10,0"
    Cursor="Hand"
    AutoGenerateColumns="False" 
    AlternateRowBackground="{StaticResource GridRowBackgroundColorBrush}"
    AlternationCount="2"                        
    CanUserFreezeColumns="False"                        
    CanUserDeleteRows="False" 
    CanUserInsertRows="False"   
    ColumnWidth="*"
    IsReadOnly="True"
    IsSynchronizedWithCurrentItem="False"                
    ShowGroupPanel="False"
    RowIndicatorVisibility="Collapsed"              
    HorizontalAlignment="Stretch" 
    VerticalAlignment="Stretch"
    IsBusy="{Binding IsBusy, ElementName=RadDomainDataSourceOrgUnit}"
    ItemsSource="{Binding DataView, ElementName=RadDomainDataSourceOrgUnit}" />


and this is the .cs code:
public void LoadInfo(string subsidiary, object orgUnitType, string adminLevel)
{               
    this.DashboardSubsidiary = subsidiary;
    this.CreateGridColumns();
    this.DataContext = this;            
}
  
private void RadDomainDataSourceOrgUnit_LoadingData(object sender, Telerik.Windows.Controls.DomainServices.LoadingDataEventArgs e)
{
    e.LoadBehavior = LoadBehavior.RefreshCurrent;
}

the private method RadDomainDataSourceOrgUnit_LoadingData is not working in my case, or the variable is not changing... if I call the Load method of the RadDomainDataSource, I need to control the textbox that I'm using to search (I removed in this example) data... because the property AutoLoad should be False.

Any idea?
Thanks.
0
Nedyalko Nikolov
Telerik team
answered on 01 Jul 2011, 01:57 PM
Hi Chris Thierry,

Could you please try your scenario with our latest internal build (2011.1.0627)? If the problem persists please send me a sample application, which I can debug on my side in order to see what is going on.
Thank you in advance.

Regards,
Nedyalko Nikolov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Chris Thierry
Top achievements
Rank 1
answered on 01 Jul 2011, 06:28 PM
I'll try with the latest internal build, what you said is that it should work exactly with my scenario?, my code is correct?, I'll try to prepare something but it will be difficult.
Thank you.
0
Chris Thierry
Top achievements
Rank 1
answered on 04 Jul 2011, 01:56 PM
HI.
the latest internal build (2011.1.0627) doesn't work either, is there any other way to do it? maybe if I do everything in the code behind?, I'm not using MVVM. Please I need a solution for this.

I have another idea... if I try to update the QueryParameters in the code-behind, where should I do it?, I have a control that loads a RadGridView, when I call this control from my page, I'll update my parameters but I want to be sure that the QueryParameters update is executed before going to the server.
 
Thank you. 

0
Chris Thierry
Top achievements
Rank 1
answered on 04 Jul 2011, 03:10 PM
HI,

I found a solution, please let me know if this is ok!

The xaml code is the same as before, the difference is instead of assigning a value to "subsidiary" parameter in the xaml page, I do this in the code-behind like this:

public void LoadInfo(string subsidiary, object orgUnitType, string adminLevel) 
{                
    this.DashboardSubsidiary = subsidiary; 
    RadDomainDataSourceOrgUnit.QueryParameters.Single(p => p.ParameterName == "subsidiary").Value = subsidiary;
    this.CreateGridColumns(); 
      
    //this.DataContext = this;  (don't need this anymore)
  
private void RadDomainDataSourceOrgUnit_LoadingData(object sender, Telerik.Windows.Controls.DomainServices.LoadingDataEventArgs e) 
    e.LoadBehavior = LoadBehavior.RefreshCurrent; 
}

LoadInfo is called from the page that has inside my user control, the RadDomainDataSource and the RadGridView xaml code is defined in my previous post, I want to be sure that the AutoLoad is executed after changing all my parameters... in my example I have only one paramater "subsidiary" but in my real code I have more, so I want to be sure that all parameters are changed and right after that, the AutoLoad is executed with the new values.

Thank you.
0
Chris Thierry
Top achievements
Rank 1
answered on 04 Jul 2011, 10:19 PM
HI,
I have another question...

How can I remove all rows of a RadGridView that is using a RadDomainDataSource?, I can't use ItemsSource = null because I don't see any record after... (I'm talking about my previous post), the problem is a visual problem for a couple of seconds.

First I'm reading data in my RadGridView using RadDomainDataSource, then I have a button to read something different in the same RadGridView, my first read has only one column, my second read has two columns.
As soon as I click the button, I see the two columns but with data of my previous read, and right after that is refreshing the data correctly, it's just a couple of seconds, I'm using AutoLoad=True.

I used this:
this.context.EntityContainer.GetEntitySet<myClass>().Clear();
when I'm not using RadDomainDataSource, but is not working in this case.

Is there any way of remove all rows in the right moment before showing the second read?
Thank you. 
0
Nedyalko Nikolov
Telerik team
answered on 05 Jul 2011, 03:04 PM
Hi Chris Thierry,

Generally both approaches should work, since they are almost equal. Unfortunately I cannot guess what is going on with the first (xaml + binding) approach without a sample project.

(Answer to the last post)
Do you mean that RadGridView shows old data while loading is in progress? If so you could use RadGridView.IsBusy property bound to RadDomainDataSource.IsBusy. Then you will see a busy indicator while loading is in progress.

Best wishes,
Nedyalko Nikolov
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

Tags
DomainDataSource
Asked by
AP
Top achievements
Rank 1
Iron
Iron
Veteran
Answers by
Yavor Georgiev
Telerik team
AP
Top achievements
Rank 1
Iron
Iron
Veteran
sebastian
Top achievements
Rank 1
Chris Thierry
Top achievements
Rank 1
Nedyalko Nikolov
Telerik team
Share this question
or