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

GridViewComboBoxColumn Issues

3 Answers 155 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Thomas
Top achievements
Rank 1
Thomas asked on 11 May 2010, 10:15 AM
Hi,
after I installed the latest build, 210.1.430.35,
my gridviewcomboboxcolumn gives exceptions, also cellstyle doesn't seem to work properly.
After  an item is added  to the itemssource of the comboboxcolumn inside the roweditended event handler of the radgridview, the following exception occurs after leaving this eventhandler:

System.ArgumentOutOfRangeException was unhandled by user code
  Message=Specified argument was out of the range of valid values.
Parameter name: index
  Source=Telerik.Windows.Data
  ParamName=index
  StackTrace:
       at Telerik.Windows.Data.QueryableCollectionView.GetItemAt(Int32 index) in c:\Builds\WPF_Scrum\Core_WPF_2010_Q1\Sources\Development\Core\Data\Collections\QueryableCollectionView.cs:line 1202
       at Telerik.Windows.Data.DataItemCollection.get_Item(Int32 index) in c:\Builds\WPF_Scrum\Core_WPF_2010_Q1\Sources\Development\Core\Data\Collections\DataItemCollection.cs:line 431
       at Telerik.Windows.Controls.GridView.GridViewItemContainerGenerator.Generator.GenerateNext(Boolean stopAtRealized, Boolean& isNewlyRealized) in c:\Builds\WPF_Scrum\GridView_WPF_2010_Q1\Sources\Development\Controls\GridView\GridView\GridView\ItemsControl\GridViewItemContainerGenerator.cs:line 1204
       at Telerik.Windows.Controls.GridView.GridViewItemContainerGenerator.System.Windows.Controls.Primitives.IItemContainerGenerator.GenerateNext(Boolean& isNewlyRealized) in c:\Builds\WPF_Scrum\GridView_WPF_2010_Q1\Sources\Development\Controls\GridView\GridView\GridView\ItemsControl\GridViewItemContainerGenerator.cs:line 236
       at Telerik.Windows.Controls.GridView.GridViewVirtualizingPanel.MeasureOverride(Size constraint) in c:\Builds\WPF_Scrum\GridView_WPF_2010_Q1\Sources\Development\Controls\GridView\GridView\GridView\Virtualization\GridViewVirtualizingPanel.cs:line 1199
       at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
       at System.Windows.UIElement.Measure(Size availableSize)
       at System.Windows.ContextLayoutManager.UpdateLayout()
       at System.Windows.ContextLayoutManager.UpdateLayoutCallback(Object arg)
       at System.Windows.Media.MediaContext.InvokeOnRenderCallback.DoWork()
       at System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks()
       at System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget)
       at System.Windows.Media.MediaContext.RenderMessageHandler(Object resizedCompositionTarget)
       at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
       at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
  InnerException:

The following style doesn't work with the latest build:
 <telerik:GridViewComboBoxColumn Header="Zit in"
                                                                     DataMemberBinding="{Binding ComponentCode}"
                                                                     DisplayMemberPath="SchemaCode"
                                                                          
                                                                     SelectedValueMemberPath=""
                                                                     EditTriggers="CellClick"
                                                                     ItemsSource="{Binding Source={StaticResource ParentSchemaCodes}}">
                                                    <telerik:GridViewComboBoxColumn.CellStyle>
                                                        <Style TargetType="{x:Type telerik:GridViewCell}">
                                                            <Setter Property="FontWeight" Value="Bold"/>
                                                            <Setter Property="Foreground" Value="DarkBlue"/>
                                                           
                                                            <Style.Triggers>
                                                                <DataTrigger Binding="{Binding IsVervallen}" Value="True">
                                                                    <Setter Property="Background" Value="#50FF0000"/>
                                                                </DataTrigger>
                                                            </Style.Triggers>
                                                        </Style>

                                                    </telerik:GridViewComboBoxColumn.CellStyle>
                                                </telerik:GridViewComboBoxColumn>

Thanks,
Thomas

3 Answers, 1 is accepted

Sort by
0
Pavel Pavlov
Telerik team
answered on 13 May 2010, 03:08 PM
Hello Thomas,

We are going to fix the problem with the style immediately . I will do my best to include the fix in the internal build tomorrow.
Can you please paste me the code you execute on RowEditEnded event so that I can step through it and address the issue as well.

Sincerely yours,
Pavel Pavlov
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
Thomas
Top achievements
Rank 1
answered on 25 May 2010, 07:58 AM
Hi,

I made a small application that reproduces the problem with the new dll's (2010.1.521.35). The cause of the problem is resetting the itemssource in the roweditended handler. Also the style still isn't working fine. The color of the cell is black instead of green.
Thanks in advance,
Thomas

Imports System.Collections.ObjectModel  
Imports Telerik.Windows.Controls  
Imports Telerik.Windows.Controls.GridView  
 
Class MainWindow  
 
    Private cars As New List(Of Car)  
    Private cartypes As New List(Of CarType)  
    Private btnState As Boolean = False 
 
    Private Sub MainWindow_Loaded(ByVal sender As ObjectByVal e As System.Windows.RoutedEventArgs) Handles Me.Loaded  
        cartypes.Add(New CarType With {.CarTypeID = 1, .Type = "Ford"})  
        cartypes.Add(New CarType With {.CarTypeID = 2, .Type = "Mercedes"})  
 
        cars.Add(New Car With {.Owner = "You", .CarTypeID = 1})  
 
        GridView1.ItemsSource = From c In cars  
        CType(GridView1.Columns(1), GridViewComboBoxColumn).ItemsSource = cartypes  
    End Sub 
 
    Private Sub GridView1_RowEditEnded(ByVal sender As System.ObjectByVal e As Telerik.Windows.Controls.GridViewRowEditEndedEventArgs)  
 
        If e.EditAction = GridView.GridViewEditAction.Commit Then 
            If e.EditOperationType = GridView.GridViewEditOperationType.Insert Then 
                cars.Add(e.NewData)  
                GridView1.Rebind()  
                GridView1.SelectedItem = e.NewData  
                GridView1.ItemsSource = From c In cars Where c.CarTypeID = 0  
                 
            End If 
        End If 
        Dim row As GridViewNewRow = TryCast(e.Row, GridViewNewRow)  
    End Sub 
 
    Private Sub button1_Click(ByVal sender As System.ObjectByVal e As System.Windows.RoutedEventArgs)  
        If Not btnState Then 
            btnState = True 
            GridView1.ItemsSource = From c In cars Where c.CarTypeID = 2  
        Else 
            btnState = False 
            GridView1.ItemsSource = From c In cars  
 
        End If 
    End Sub 
 
    Private Sub GridView1_AddingNewDataItem(ByVal sender As System.ObjectByVal e As Telerik.Windows.Controls.GridView.GridViewAddingNewEventArgs)  
        e.NewObject = New Car With {.CarTypeID = 1}  
    End Sub 
End Class 
<Window xmlns:my="http://schemas.telerik.com/2008/xaml/presentation"  x:Class="MainWindow" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
       
    Title="MainWindow">  
    <Grid> 
         
        <StackPanel> 
            <my:RadGridView Name="GridView1" AddingNewDataItem="GridView1_AddingNewDataItem" AutoGenerateColumns="False"  RowEditEnded="GridView1_RowEditEnded" CanUserInsertRows="True" ShowInsertRow="True">  
            <my:RadGridView.Columns> 
                <my:GridViewDataColumn Header="Owner" UniqueName="Owner"/>  
                    <my:GridViewComboBoxColumn Header="Type" UniqueName="CarTypeID" SelectedValueMemberPath="CarTypeID" DisplayMemberPath="Type">  
                        <my:GridViewComboBoxColumn.CellStyle> 
                            <Style TargetType="{x:Type my:GridViewCell}">  
                                <Setter Property="FontWeight" Value="Bold"/>  
                                <Setter Property="Foreground" Value="Green"/>  
 
                                 
                            </Style> 
 
                        </my:GridViewComboBoxColumn.CellStyle> 
                         
                    </my:GridViewComboBoxColumn> 
                </my:RadGridView.Columns> 
        </my:RadGridView> 
         
            </StackPanel> 
    </Grid> 
</Window> 
 
0
Pavel Pavlov
Telerik team
answered on 31 May 2010, 12:01 PM
Hi Thomas,
Thanks for reporting these issues.
On the Style related problem :
It seems we were missing some bindings in the default template of the combo box column.
Thanks to your feedback this has been fixed and will be available in the service pack (scheduled for tomorrow).  I am updating your Telerik points.

Regarding the exception problem :
I have been able to reproduce it here. As a workaround I have found that if you convert to list the grid view ItemsSource , the exception is no more being thrown.
e.g. in the sample app :

GridView1.ItemsSource = (From c In cars).ToList()

and

GridView1.ItemsSource = (From c In cars Where c.CarTypeID = 0).ToList()


Regards,
Pavel Pavlov
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.
Tags
GridView
Asked by
Thomas
Top achievements
Rank 1
Answers by
Pavel Pavlov
Telerik team
Thomas
Top achievements
Rank 1
Share this question
or