UXGridView refresh button problem

6 replies. Last post: October 25, 2011 3:41 AM by Michael Giger
Tags :

Hi

When I click the refresh button of UXGridView, the data is reloaded, but the view is not refreshed! Cache problem? How can I change this behavior?

This is the response from domain service:

000003B0  06 00 00 00 00 00 00 9F  02 1C 5B 01 5F 0E 50 72   ..........[._.Pr
000003C0  6F 64 75 63 74 69 6F 6E  4C 69 6E 65 5F 04 48 69   oductionLine_.Hi
000003D0  64 65 85 5F 02 49 44 99  24 32 35 64 61 30 33 33   de._.ID.$25da033
000003E0  62 2D 37 31 38 61 2D 36  33 61 37 2D 62 37 31 33   b-718a-63a7-b713
000003F0  2D 32 34 64 35 62 62 32  32 34 36 30 62 5F 04 4E   -24d5bb22460b_.N
00000400  61 6D 65 99 09 53 4C 52  20 4C 69 6E 69 65 5F 07   ame..SLR Linie_.
00000410  56 65 72 73 69 6F 6E 9E  06 00 00 00 00 00 00 9F   Version.........
00000420  02 1C 5A 01 5F 0E 50 72  6F 64 75 63 74 69 6F 6E   ..Z._.Production
00000430  4C 69 6E 65 5F 04 48 69  64 65 85 5F 02 49 44 99   Line_.Hide._.ID.
00000440  24 64 39 62 36 66 37 35  65 2D 35 33 37 33 2D 34   $d9b6f75e-5373-4
00000450  30 65 37 2D 39 33 34 64  2D 31 35 39 38 35 31 30   0e7-934d-1598510
00000460  62 38 36 62 61 5F 04 4E  61 6D 65 99 07 58 58 58   b86ba_.Name..XXX
00000470  58 31 32 33 5F 07 56 65  72 73 69 6F 6E 9E 06 00   X123_.Version...
00000480  00 00 00 00 00 9F 02 27  1E 01 01 01 01            .......'.....

The UXGridView shows still XXXX00. Have a look at attached picture.

reproducible test steps:

- Load data
- Record changed directly into SQL DB (Simulation of multiuser application)
- Refresh button clicked


Environment:

- SQL Server 2008 R2
- Entity Framework 4
- Domainservice (Ria Services)
- ClientUI MVVM Business Application (Silverlight)

 

Refresh Button works fine with "new item" and "delete item".  This behavior occurs only with "edit item".

Regards

Michael

Answers

Yudi Member

Following section shows the steps to bind the refresh button to a command that will refresh data and clear the cache. Specifically the “clear cache” mechanism is done by clearing the contents of entity set.

Note: the step-by-step made based on the “Intersoft ClientUI MVVM Data Application (WCF RIA SP1).

  1. Open Products.xaml file in Expression Blend to edit the template of “Refresh Button”.
  2. Create a copy of template and find the “Refresh” UXFlatButton.
  3. <Intersoft:UXStatusBarItem>
        <Intersoft:UXFlatButton Command="core:DataViewCommands.Refresh"
                                Icon="/Intersoft.Client.UI.Data;component/Resources/refresh.png"
                                Style="{StaticResource CommandButtonStyle}"/>
    </Intersoft:UXStatusBarItem>
  4. Modify and set the Command property as shown in the following code.
  5. <Intersoft:UXStatusBarItem>
        <Intersoft:UXFlatButton Command="{Binding RefreshCommand}"
                                Icon="/Intersoft.Client.UI.Data;component/Resources/refresh.png"
                                Style="{StaticResource CommandButtonStyle}"/>
    </Intersoft:UXStatusBarItem>
  6. Open “\ViewModels.Infrastructure\EditableGridViewModelGenericBase.cs” and define “RefreshCommand” as delegated method.
  7. #region Commands
    
    ...
    
    /// <summary>
    /// Gets or sets a <see cref="DelegateCommand"/> to handle refresh operation.
    /// </summary>
    public DelegateCommand RefreshCommand { get; set; }
    
    #endregion
  8. Create the method that will be triggered when “Refresh” button is clicked.
  9. #region Methods
    
    ...
    
    private void ExecuteRefresh(object parameter)
    {
        this.DataSource.Context.EntityContainer.Clear();
        this.LoadData();
    }
    
    #endregion
  10. In the constructor, set a DelegateCommand to handle refresh operation. After this step, the constructor should look like following.
  11. #region Constructor
    
    /// <summary>
    /// Initializes a new instance of the <see cref="EditableGridViewModelBase"/> class.
    /// </summary>
    public EditableGridViewModelBase()
        : base()
    {
        ...
        this.RefreshCommand = new DelegateCommand(ExecuteRefresh);
    }
    
    #endregion
  12. Open “\ModelServices.Infrastructure\IDataRepository.cs” class and add the following line to the IDataRepository interface.
  13. public interface IDataRepository
    {
        ...
    
        DomainContext Context { get; }
    }
  14. Save all the changes and build the project.

I have tested this approach on my local end. Please kindly let me know if you find any difficulties to implement this. I’d be glad to send you a working sample.

Thank you and have a nice day.

Hi Yudi

Thanks for excellent support!

I have skipped the first three steps, because I've bound the command directly to the UXGridView (see last line of code). It works fine.

<Intersoft:UXGridView Intersoft:DockPanel.IsFillElement="True" AutoGenerateColumns="False"
    Style="{StaticResource UXGridViewStyle}"
    IsBusy="{Binding IsBusy, Mode=TwoWay}" 
    IsRefreshed="{Binding IsRefreshed, Mode=TwoWay}"
    SortDescriptors="{Binding QueryDescriptor.SortDescriptors, Mode=TwoWay}"
    PageDescriptor="{Binding QueryDescriptor.PageDescriptor}"
    FilterDescriptors="{Binding QueryDescriptor.FilterDescriptors, Mode=TwoWay}"
    PageSize="{Binding ElementName=PageSize, Path=Text}"
    ItemsSource="{Binding Path=Items}"
    SelectedItem="{Binding SelectedItem, Mode=TwoWay}"
    NewItem="{Binding NewItem, Mode=TwoWay}"
    HasChanges="{Binding HasChanges}"
    AutoEditOperation="{Binding AutoEditOperation}" 
    PrepareNewRowCommand="{Binding PrepareNewRowCommand}"
    ValidateRowCommand="{Binding ValidateRowCommand}" 
    InsertRowCommand="{Binding InsertRowCommand}"
    DeleteRowCommand="{Binding DeleteRowCommand}" 
    UpdateCellCommand="{Binding UpdateCellCommand}" 
    UpdateRowCommand="{Binding UpdateRowCommand}"
    SaveChangesCommand="{Binding SaveChangesCommand}" 
    RejectRowCommand="{Binding RejectRowCommand}"
    RejectChangesCommand="{Binding RejectChangesCommand}"
    RefreshCommand="{Binding RefreshCommand}">

Regards

Michael

 

 

All Replies

Yudi Member

This problem is not caused by the cache problem.

The “Refresh” button in our UXGridView sample or project template is not bind to any command (refresh command) yet. You can try to add your own command that will, for example, clear the cached data and then reload the data.

Hope this helps.

Hi Yudi

Yes, I have seen that UXGridView refresh command is not bind. But if I click on refreshbutton, a request is running (see my first post). Can I not use this query directly? Run the query twice after?

Regards

Michael

Yudi Member

Apologize for lack of understanding about the required scenario.
Could you please kindly add more detail about the terms “Can I not use this query directly? Run the query twice after?”

Hi Yudi

Please excuse the unclear description!
 
I would that the data is loaded and displayed if I click on refresh button in the statusbar. In I have seen in Expression Blend that refresh button is bound as follows:
 
<Intersoft:UXStatusBarItem>
    <Intersoft:UXFlatButton Command="core:DataViewCommands.Refresh" Icon="/Intersoft.Client.UI.Data;component/Resources/refresh.png" Style="{StaticResource CommandButtonStyle}"/>
</Intersoft:UXStatusBarItem>

This command is overridden with UXGridView refresh command? I had thought it would run both commands...

How can I clear the cached data?
 
Thank you for your much appreciated work!
 
Regards
Michael
Yudi Member

Following section shows the steps to bind the refresh button to a command that will refresh data and clear the cache. Specifically the “clear cache” mechanism is done by clearing the contents of entity set.

Note: the step-by-step made based on the “Intersoft ClientUI MVVM Data Application (WCF RIA SP1).

  1. Open Products.xaml file in Expression Blend to edit the template of “Refresh Button”.
  2. Create a copy of template and find the “Refresh” UXFlatButton.
  3. <Intersoft:UXStatusBarItem>
        <Intersoft:UXFlatButton Command="core:DataViewCommands.Refresh"
                                Icon="/Intersoft.Client.UI.Data;component/Resources/refresh.png"
                                Style="{StaticResource CommandButtonStyle}"/>
    </Intersoft:UXStatusBarItem>
  4. Modify and set the Command property as shown in the following code.
  5. <Intersoft:UXStatusBarItem>
        <Intersoft:UXFlatButton Command="{Binding RefreshCommand}"
                                Icon="/Intersoft.Client.UI.Data;component/Resources/refresh.png"
                                Style="{StaticResource CommandButtonStyle}"/>
    </Intersoft:UXStatusBarItem>
  6. Open “\ViewModels.Infrastructure\EditableGridViewModelGenericBase.cs” and define “RefreshCommand” as delegated method.
  7. #region Commands
    
    ...
    
    /// <summary>
    /// Gets or sets a <see cref="DelegateCommand"/> to handle refresh operation.
    /// </summary>
    public DelegateCommand RefreshCommand { get; set; }
    
    #endregion
  8. Create the method that will be triggered when “Refresh” button is clicked.
  9. #region Methods
    
    ...
    
    private void ExecuteRefresh(object parameter)
    {
        this.DataSource.Context.EntityContainer.Clear();
        this.LoadData();
    }
    
    #endregion
  10. In the constructor, set a DelegateCommand to handle refresh operation. After this step, the constructor should look like following.
  11. #region Constructor
    
    /// <summary>
    /// Initializes a new instance of the <see cref="EditableGridViewModelBase"/> class.
    /// </summary>
    public EditableGridViewModelBase()
        : base()
    {
        ...
        this.RefreshCommand = new DelegateCommand(ExecuteRefresh);
    }
    
    #endregion
  12. Open “\ModelServices.Infrastructure\IDataRepository.cs” class and add the following line to the IDataRepository interface.
  13. public interface IDataRepository
    {
        ...
    
        DomainContext Context { get; }
    }
  14. Save all the changes and build the project.

I have tested this approach on my local end. Please kindly let me know if you find any difficulties to implement this. I’d be glad to send you a working sample.

Thank you and have a nice day.

Hi Yudi

Thanks for excellent support!

I have skipped the first three steps, because I've bound the command directly to the UXGridView (see last line of code). It works fine.

<Intersoft:UXGridView Intersoft:DockPanel.IsFillElement="True" AutoGenerateColumns="False"
    Style="{StaticResource UXGridViewStyle}"
    IsBusy="{Binding IsBusy, Mode=TwoWay}" 
    IsRefreshed="{Binding IsRefreshed, Mode=TwoWay}"
    SortDescriptors="{Binding QueryDescriptor.SortDescriptors, Mode=TwoWay}"
    PageDescriptor="{Binding QueryDescriptor.PageDescriptor}"
    FilterDescriptors="{Binding QueryDescriptor.FilterDescriptors, Mode=TwoWay}"
    PageSize="{Binding ElementName=PageSize, Path=Text}"
    ItemsSource="{Binding Path=Items}"
    SelectedItem="{Binding SelectedItem, Mode=TwoWay}"
    NewItem="{Binding NewItem, Mode=TwoWay}"
    HasChanges="{Binding HasChanges}"
    AutoEditOperation="{Binding AutoEditOperation}" 
    PrepareNewRowCommand="{Binding PrepareNewRowCommand}"
    ValidateRowCommand="{Binding ValidateRowCommand}" 
    InsertRowCommand="{Binding InsertRowCommand}"
    DeleteRowCommand="{Binding DeleteRowCommand}" 
    UpdateCellCommand="{Binding UpdateCellCommand}" 
    UpdateRowCommand="{Binding UpdateRowCommand}"
    SaveChangesCommand="{Binding SaveChangesCommand}" 
    RejectRowCommand="{Binding RejectRowCommand}"
    RejectChangesCommand="{Binding RejectChangesCommand}"
    RefreshCommand="{Binding RefreshCommand}">

Regards

Michael

 

 

All times are GMT -5. The time now is 9:15 PM.
Previous Next