Not sure if this is a bug or not
I suspect it is
I have a Radgrid in a HierarchyChildTemplate with a comboxcolumn
it order to get the Itemssource to the comboboxolumn for the lookup i have hooked the
loaded event of the grid and load the itemsource like so
Problem is the initial value of that column is not shown even though it is in the data.
If i click in the cell to edit
The value is already selected (from the combo box)
and when leaving edit mode is now shown in the cell.
so the questions:
I suspect it is
I have a Radgrid in a HierarchyChildTemplate with a comboxcolumn
it order to get the Itemssource to the comboboxolumn for the lookup i have hooked the
loaded event of the grid and load the itemsource like so
<telerikGridView:RadGridView.HierarchyChildTemplate> |
<DataTemplate> |
<telerikGridView:RadGridView ItemsSource="{Binding lstTestClass}" AutoGenerateColumns="False" Loaded="SetUpChildComboBox"> |
<telerikGridView:RadGridView.Columns > |
<telerikGridView:GridViewSelectColumn></telerikGridView:GridViewSelectColumn> |
<telerikGridView:GridViewDataColumn DataMemberBinding="{Binding iQty,Mode=TwoWay}" /> |
<telerikGridView:GridViewComboBoxColumn UniqueName="ComboCol" DisplayMemberPath="NameState" SelectedValueMemberPath="IDState" DataMemberBinding="{Binding IDState}" /> |
</telerikGridView:RadGridView.Columns> |
</telerikGridView:RadGridView> |
</DataTemplate> |
</telerikGridView:RadGridView.HierarchyChildTemplate> |
Private Sub SetUpChildComboBox(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) |
Dim RadGridview As RadGridView = DirectCast(sender, RadGridView) |
DirectCast(RadGridview.Columns("ComboCol"), GridViewComboBoxColumn).ItemsSource = collStates |
End Sub |
Problem is the initial value of that column is not shown even though it is in the data.
If i click in the cell to edit
The value is already selected (from the combo box)
and when leaving edit mode is now shown in the cell.
so the questions:
- am i hooking the wrong event
- is there another/better way to do it
- is it a bug
i have included screenshots of the problem.
thanks
dco
below find the test project i made to highlight and test the issue.
<UserControl xmlns:telerikGridView="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.GridView" x:Class="agTestBed.MainPage" |
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" |
mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480"> |
<Grid x:Name="LayoutRoot"> |
<telerikGridView:RadGridView x:Name="TestGrid" SelectionMode="Multiple" AutoGenerateColumns="False"> |
<telerikGridView:RadGridView.HierarchyChildTemplate> |
<DataTemplate> |
<telerikGridView:RadGridView ItemsSource="{Binding lstTestClass}" AutoGenerateColumns="False" Loaded="SetUpChildComboBox"> |
<telerikGridView:RadGridView.Columns > |
<telerikGridView:GridViewSelectColumn></telerikGridView:GridViewSelectColumn> |
<telerikGridView:GridViewDataColumn DataMemberBinding="{Binding iQty,Mode=TwoWay}" /> |
<telerikGridView:GridViewComboBoxColumn UniqueName="ComboCol" DisplayMemberPath="NameState" SelectedValueMemberPath="IDState" DataMemberBinding="{Binding IDState}" /> |
</telerikGridView:RadGridView.Columns> |
</telerikGridView:RadGridView> |
</DataTemplate> |
</telerikGridView:RadGridView.HierarchyChildTemplate> |
<telerikGridView:RadGridView.Columns> |
<telerikGridView:GridViewSelectColumn></telerikGridView:GridViewSelectColumn> |
<telerikGridView:GridViewDataColumn DataMemberBinding="{Binding iQty,Mode=TwoWay}" ></telerikGridView:GridViewDataColumn> |
<telerikGridView:GridViewComboBoxColumn UniqueName="ComboCol" DisplayMemberPath="NameState" SelectedValueMemberPath="IDState" DataMemberBinding="{Binding IDState}" /> |
</telerikGridView:RadGridView.Columns> |
</telerikGridView:RadGridView> |
</Grid> |
</UserControl> |
Imports System.Windows.Data |
Imports System.Windows.Ria.Data |
Imports Telerik.Windows.Controls |
Imports Telerik.Windows.Data |
Imports System.ComponentModel |
Imports System.ComponentModel.DataAnnotations |
Imports System.Collections.ObjectModel |
Imports System.Runtime.CompilerServices |
Partial Public Class MainPage |
Inherits UserControl |
Public Sub New() |
InitializeComponent() |
End Sub |
Public CollTestclass As New ObservableCollection(Of TestClass) |
Public collStates As New ObservableCollection(Of State) |
Private Sub MainPage_Loaded(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles Me.Loaded |
'create states list data |
collStates.Add(New State With {.IDState = "0", .NameState = "FL"}) |
collStates.Add(New State With {.IDState = "1", .NameState = "GA"}) |
' create test data |
CollTestclass.Add(New TestClass With {.iQty = 1, .IDState = "0", .lstTestClass = Makeitup()}) |
CollTestclass.Add(New TestClass With {.iQty = 2, .IDState = "1", .lstTestClass = Makeitup()}) |
CollTestclass.Add(New TestClass With {.iQty = 3, .IDState = "1", .lstTestClass = Makeitup()}) |
CollTestclass.Add(New TestClass With {.iQty = 4, .IDState = "0", .lstTestClass = Makeitup()}) |
CollTestclass.Add(New TestClass With {.iQty = 5, .IDState = "1", .lstTestClass = Makeitup()}) |
CollTestclass.Add(New TestClass With {.iQty = 6, .IDState = "0", .lstTestClass = Makeitup()}) |
CollTestclass.Add(New TestClass With {.iQty = 7, .IDState = "1", .lstTestClass = Makeitup()}) |
' set child table definition |
Dim detailDefinition As New GridViewTableDefinition() |
detailDefinition.Relation = New PropertyRelation("lstTestClass") |
TestGrid.TableDefinition.ChildTableDefinitions.Add(detailDefinition) |
' set up main grid datasources |
DirectCast(TestGrid.Columns("ComboCol"), GridViewComboBoxColumn).ItemsSource = collStates |
TestGrid.ItemsSource = CollTestclass |
End Sub |
Public Function Makeitup() As ObservableCollection(Of TestClass) |
Dim CollTestclass As New ObservableCollection(Of TestClass) |
CollTestclass.Add(New TestClass With {.iQty = 1, .IDState = "0"}) |
CollTestclass.Add(New TestClass With {.iQty = 2, .IDState = "1"}) |
CollTestclass.Add(New TestClass With {.iQty = 3, .IDState = "1"}) |
CollTestclass.Add(New TestClass With {.iQty = 4, .IDState = "0"}) |
CollTestclass.Add(New TestClass With {.iQty = 5, .IDState = "1"}) |
CollTestclass.Add(New TestClass With {.iQty = 6, .IDState = "0"}) |
CollTestclass.Add(New TestClass With {.iQty = 7, .IDState = "1"}) |
Return CollTestclass |
End Function |
Private Sub SetUpChildComboBox(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) |
Dim RadGridview As RadGridView = DirectCast(sender, RadGridView) |
DirectCast(RadGridview.Columns("ComboCol"), GridViewComboBoxColumn).ItemsSource = collStates |
End Sub |
Private Sub TestGrid_DataLoaded(ByVal sender As Object, ByVal e As System.EventArgs) Handles TestGrid.DataLoaded |
End Sub |
Private Sub TestGrid_Loaded(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles TestGrid.Loaded |
End Sub |
End Class |
Public Class State |
<Display(Name:="IDState", Description:="IDState")> _ |
Public Property IDState() As String |
Get |
Return _IDState |
End Get |
Set(ByVal value As String) |
_IDState = value |
End Set |
End Property |
Protected _IDState As String |
<Display(Name:="NameState", Description:="NameState")> _ |
Public Property NameState() As String |
Get |
Return _NameState |
End Get |
Set(ByVal value As String) |
_NameState = value |
End Set |
End Property |
Protected _NameState As String |
End Class |
Public Class TestClass |
Implements INotifyPropertyChanged |
Public Event PropertyChanged(ByVal sender As Object, ByVal e As System.ComponentModel.PropertyChangedEventArgs) Implements System.ComponentModel.INotifyPropertyChanged.PropertyChanged |
Private Sub FirePropertyChanged(ByVal [property] As String) |
If Not String.IsNullOrEmpty([property]) Then |
RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs([property])) |
End If |
End Sub |
<Display(Name:="iQty", Description:="iQty")> _ |
Public Property iQty() As Integer |
Get |
Return _iQty |
End Get |
Set(ByVal value As Integer) |
_iQty = value |
FirePropertyChanged("iQty") |
End Set |
End Property |
Protected _iQty As Integer |
<Display(Name:="IDState", Description:="IDState")> _ |
Public Property IDState() As String |
Get |
Return _IDState |
End Get |
Set(ByVal value As String) |
_IDState = value |
FirePropertyChanged("IDState") |
End Set |
End Property |
Protected _IDState As String |
<Display(Name:="lstTestClass", Description:="lstTestClass")> _ |
Public Property lstTestClass() As ObservableCollection(Of TestClass) |
Get |
Return _lstTestClass |
End Get |
Set(ByVal value As ObservableCollection(Of TestClass)) |
_lstTestClass = value |
FirePropertyChanged("lstTestClass") |
End Set |
End Property |
Protected _lstTestClass As ObservableCollection(Of TestClass) |
End Class |