Group header data is not dynamically changing

5 posts, 0 answers
  1. Sandro
    Sandro avatar
    18 posts
    Member since:
    Jan 2011

    Posted 10 Oct 2011 Link to this post

    Hi

    I have a problem on dynamically change the data on the group data row of RadGridView. Our application has a feature of translating the text into different languages like french, german and etc. We are using observablecollection object and binded to a RadGridview. When we change data to the obsevablecollection (by changing language) , the RadGridview is also reacts to the changes on the observablecollection however the group data row data is not changing. I used the GroupDescriptor of RadGridView.
    Can you help me solve this problem?
    Thank you in advance
  2. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 10 Oct 2011 Link to this post

    Hi Sandro,

    Would you clarify a bit what is the exact scenario that you want to accomplish ? Do you try to localize your RadGridView as in our example ?  Or you want only to update the items written in different language ? Do you change the groups in any way ?
    Generally, any relevant information or code-snippet describing your settings would be helpful.

    Kind regards,
    Maya
    the Telerik team

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

  3. Sandro
    Sandro avatar
    18 posts
    Member since:
    Jan 2011

    Posted 10 Oct 2011 Link to this post

    Here are my example code.

    I have a combobox with 2 items. When you change the selected index of the combo, it also change dynamically the child record, however the group record is not changing.

    <UserControl x:Class="Sample.MainPage"
    xmlns:ViewModels="clr-namespace:Sample.ViewModel"
    mc:Ignorable="d"
    <UserControl.Resources>
    <ViewModels:vmMainPage x:Key="ViewMain" />
    </UserControl.Resources>
    <Grid x:Name="LayoutRoot" Background="White" DataContext="{Binding Source={StaticResource ViewMain}}">
    <telerik:RadGridView Height="232" HorizontalAlignment="Left" Margin="22,43,0,0" Name="RadGridView1" VerticalAlignment="Top" Width="347" ItemsSource="{Binding Path=Products}" AutoGenerateColumns="False" ShowGroupPanel="False">
    <telerik:RadGridView.Columns>
    <telerik:GridViewDataColumn DataMemberBinding="{Binding Category}" IsVisible="False" Header="Category" IsReadOnly="True" Width="100" MinWidth="100"/>
    <telerik:GridViewDataColumn DataMemberBinding="{Binding Name}" Header="Product" IsReadOnly="True" Width="100" MinWidth="100"/>
    </telerik:RadGridView.Columns>
    <telerik:RadGridView.GroupDescriptors>
    <telerik:GroupDescriptor Member="Category" />
    </telerik:RadGridView.GroupDescriptors>
    </telerik:RadGridView>
    <sdk:Label Height="26" HorizontalAlignment="Left" Margin="24,6,0,0" Name="Label1" VerticalAlignment="Top" Width="82" Content="Language" />
    <ComboBox SelectedIndex="{Binding SelectedLanguage,Mode=TwoWay}" Height="24" HorizontalAlignment="Left" Margin="102,8,0,0" Name="ComboBox1" VerticalAlignment="Top" Width="164">
    <ComboBoxItem Content="English" />
    <ComboBoxItem Content="German" />
    </ComboBox>
    </Grid>
    </UserControl>
    Imports
    System.ComponentModel
    Imports System.Collections.ObjectModel
    Namespace ViewModel
    Public Class vmMainPage
    Implements INotifyPropertyChanged
    Sub New()
    _SelectedLanguage = 0
    _myProduct = New ObservableCollection(Of clsProduct)
    _myProduct.Add(New clsProduct With {.Category = "Category 1", .Name = "Product 1"})
    _myProduct.Add(New clsProduct With {.Category = "Category 2", .Name = "Product 2"})
    End Sub
    Private _myProduct As ObservableCollection(Of clsProduct)
    Public Property Products As ObservableCollection(Of clsProduct)
    Get
    Return _myProduct
    End Get
    Set(ByVal value As ObservableCollection(Of clsProduct))
    _myProduct = value
    OnPropertyChanged("Products")
    End Set
    End Property
    Private Sub ChangeLanguage()
    If _SelectedLanguage = 0 Then
    _myProduct(0).Category = "Category 1"
    _myProduct(0).Name = "Product 1"
    _myProduct(1).Category = "Category 2"
    _myProduct(1).Name = "Product 2"
    ElseIf _SelectedLanguage = 1 Then
    _myProduct(0).Category = "Kategorie 1"
    _myProduct(0).Name = "Produkt 1"
    _myProduct(1).Category = "Kategorie 2"
    _myProduct(1).Name = "Produkt 2"
    End If
    End Sub
    Private _SelectedLanguage As Integer
    Public Property SelectedLanguage As Integer
    Get
    Return _SelectedLanguage
    End Get
    Set(ByVal value As Integer)
    _SelectedLanguage = value
    ChangeLanguage()
    OnPropertyChanged("SelectedLanguage")
    End Set
    End Property
    Public Event PropertyChanged(ByVal sender As Object, ByVal e As System.ComponentModel.PropertyChangedEventArgs) Implements System.ComponentModel.INotifyPropertyChanged.PropertyChanged
    Protected Overridable Sub OnPropertyChanged(ByVal propName As String)
    RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(propName))
    End Sub
    End Class
    End Namespace
    Public Class clsProduct
    Implements INotifyPropertyChanged
    Private _Name As String
    Public Property Name As String
    Get
    Return _Name
    End Get
    Set(ByVal value As String)
    _Name = value
    OnPropertyChanged("Name")
    End Set
    End Property
    Private _Category As String
    Public Property Category As String
    Get
    Return _Category
    End Get
    Set(ByVal value As String)
    _Category = value
    OnPropertyChanged("Name")
    End Set
    End Property
    Public Event PropertyChanged(ByVal sender As Object, ByVal e As System.ComponentModel.PropertyChangedEventArgs) Implements System.ComponentModel.INotifyPropertyChanged.PropertyChanged
    Protected Overridable Sub OnPropertyChanged(ByVal propName As String)
    RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(propName))
    End Sub
    End Class
  4. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 10 Oct 2011 Link to this post

    Hello Sandro,

    This would be the expected behavior since the groups will be updated on CollectionChanged event, not on PropertyChanged. Please take a look at this forum thread for a reference on how to invoke CollectionChanged in similar scenario. The thread refers to updating the aggregates, but the idea is the same. 

    Best wishes,
    Maya
    the Telerik team

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

  5. Sandro
    Sandro avatar
    18 posts
    Member since:
    Jan 2011

    Posted 11 Oct 2011 Link to this post

    Hi

    Do you have any simple code just like what I sent?
    The sample code from the thread is not easy to understand.

    Thank you in advance
Back to Top