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

ArgumentOutOfRangeException in OnLostFocus() when grid has read-only columns

6 Answers 108 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Richard
Top achievements
Rank 1
Richard asked on 27 Jul 2011, 08:16 PM
Hi,


We recently upgraded to the Q2 2011 release (2011.2 712), and we began seeing exceptions from the RadGridView. This didn't happen with 2011.1 315. We're using a workaround, but we're not sure if the workaround has any negative side effects.


Our app has a RadWindow pop-up containing a RadGridView. If the user is in the middle of an edit and they then click our Cancel button to close the RadWindow, the grid throws the following exception:

System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. 
Parameter name: index 
  at Telerik.Windows.Controls.GridView.GridViewDataControl.RaiseDataErrorEvent(DataErrorEventArgs args) 
  at Telerik.Windows.Controls.GridView.GridViewDataControl.CommitCurrentEdit(GridViewRow gridViewRow) 
  at Telerik.Windows.Controls.GridView.GridViewDataControl.PerformRowEditEnded(GridViewCell currentCell) 
  at Telerik.Windows.Controls.GridView.GridViewDataControl.CommitCellEdit(GridViewCell currentCell, Boolean isLeavingRow) 
  at Telerik.Windows.Controls.GridView.GridViewDataControl.CommitEdit() 
  at Telerik.Windows.Controls.GridView.GridViewCell.HandlePendingEdit() 
  at Telerik.Windows.Controls.GridView.GridViewCell.HandlePendingEditOnLostFocus() 
  at Telerik.Windows.Controls.GridView.GridViewCell.OnLostFocus(RoutedEventArgs e) 
  at System.Windows.Controls.Control.OnLostFocus(Control ctrl, EventArgs e) 
  at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, Int32 actualArgsTypeIndex, String eventName)

Our app code is not anywhere in this stack trace, so I don't think it's our bug.


Here is the markup for our grid:

<telerik:RadGridView Grid.Row="5" Grid.Column="2" Grid.ColumnSpan="2" x:Name="gvUnderlyingGroupSymbols" ItemsSource="{Binding UnderlyingGroupSymbols}"
AutoGenerateColumns="False" AlternationCount="2" ShowGroupPanel="False"
SelectionMode="Extended" TabNavigation="Once" SelectionChanged="GvUnderlyingGroupSymbols_OnSelectionChanged" DataLoaded="GvUnderlyingGroupSymbols_DataLoaded" CanUserFreezeColumns="False"
IsEnabled="{Binding AnUnderlyingGroupIsSelected}" >
    <telerik:RadGridView.Columns>
        <telerik:GridViewDataColumn Header="Symbol" DataMemberBinding="{Binding SymbolCode}" IsReadOnly="True" />
        <telerik:GridViewDataColumn Header="Exchange" DataMemberBinding="{Binding ExchangeCode}" IsReadOnly="True" />
        <telerik:GridViewDataColumn Header="Type" DataMemberBinding="{Binding UnderlyingType}" IsReadOnly="True" />
        <telerik:GridViewComboBoxColumn
            Header="Direction"
            DataMemberBinding="{Binding Direction, Mode=TwoWay}"
            SelectedValueMemberPath="Name"
            DisplayMemberPath="Name"
             />
        <telerik:GridViewDataColumn Header="Max Position" DataMemberBinding="{Binding MaxPosition}" DataFormatString="{}{0:N0}" TextAlignment="Right" />
    </telerik:RadGridView.Columns>
</telerik:RadGridView>


If we remove the read-only columns, the problem goes away.

We found this earlier thread related to read-only columns: http://www.telerik.com/community/forums/silverlight/gridview/error-binding-gridview-to-domaindatasource.aspx. In that thread, Stefan Dobrev suggested suppressing errors from the grid using the following code:

this.gridView.DataError += (s, args) => args.Handled = true;

We tried this and it successfully prevents the exception. However, we're not sure if this also might suppress other problems that we'd actually like to know about. (Is this sort of like swallowing all exceptions with an empty 'catch' block? If so, it might hide some other bug.)


Thanks for your help,
Richard

6 Answers, 1 is accepted

Sort by
0
Yordanka
Telerik team
answered on 02 Aug 2011, 02:43 PM
Hello Richard,

I tried to reproduce the exception using the provided details but without any success. Could you isolate it in a sample project and send it to us so we can see what is going wrong? Thank you.
 
Regards,
Yordanka
the Telerik team

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

0
Tony
Top achievements
Rank 1
answered on 03 Aug 2011, 07:12 PM
Hi Yordanka,

Thanks for your help. We haven't had time yet to come up with a test project to reproduce the problem... we'll probably need to take our app and cut out everything except the problem part. For now, we've reverted to the old 2011.1 315 version, and that's working for us.

Thanks,
Richard
0
Ronald
Top achievements
Rank 1
answered on 19 Aug 2011, 10:53 AM
I also get the exception when editing a value in the grid:
Specified argument was out of the range of valid values.
Parameter name: index
Stacktrace: 
   at Telerik.Windows.Controls.GridView.GridViewDataControl.RaiseDataErrorEvent(DataErrorEventArgs args)
   at Telerik.Windows.Controls.GridView.GridViewDataControl.CommitCurrentEdit(GridViewRow gridViewRow)
   at Telerik.Windows.Controls.GridView.GridViewDataControl.PerformRowEditEnded(GridViewCell currentCell)
   at Telerik.Windows.Controls.GridView.GridViewDataControl.CommitCellEdit(GridViewCell currentCell, Boolean isLeavingRow)
   at Telerik.Windows.Controls.GridView.GridViewDataControl.CanCellBecomeCurrent(GridViewCell cell)
   at Telerik.Windows.Controls.GridView.GridViewCell.OnMouseLeftButtonDown(MouseButtonEventArgs e)
   at System.Windows.Controls.Control.OnMouseLeftButtonDown(Control ctrl, EventArgs e)
   at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, Int32 actualArgsTypeIndex, String eventName)

My Grid xaml looks like this:
<telerikGridView:RadGridView x:Name="LanguagesGridView" Margin="0" d:LayoutOverrides="Width, Height" AutoGenerateColumns="False" CanUserFreezeColumns="False" IsFilteringAllowed="False" CellEditEnded="LanguagesGridView_CellEditEnded" CanUserDeleteRows="False" CanUserInsertRows="False" EditTriggers="CellClick" CanUserSelect="False" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" Padding="0" ScrollViewer.VerticalScrollBarVisibility="Visible" ScrollViewer.HorizontalScrollBarVisibility="Visible" BeginningEdit="LanguagesGridView_BeginningEdit" MinColumnWidth="150" RowIndicatorVisibility="Collapsed">

<i:Interaction.Behaviors>

<local:ConditionalFormattingBehavior/>

 

</i:Interaction.Behaviors>

 

</telerikGridView:RadGridView>

I add the columns from code. I also have 2 readonly columns and set the FrozenColumnCount to 2
I am using silverlight controls Q2 2011

I can reproduce it in a test application, I will send it to you via a support ticket.

0
Yordanka
Telerik team
answered on 23 Aug 2011, 02:47 PM
Hi Ronald,

Please, check my reply in the other thread started by you.
 
Kind regards,
Yordanka
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
Chris
Top achievements
Rank 1
answered on 17 Oct 2011, 07:08 PM
I'm experiencing this same error as well.  I'm using v. 2001.2.920.1040.  What was your reply to Ronald's other thread?  Could you please post a link to it?

Thanks
0
Yordanka
Telerik team
answered on 20 Oct 2011, 09:44 AM
Hello Chris,

The exception was related to the outdated Silverlight DataTable version. I am attaching a solution using more recent version of the Silverlight DataTable. Also, you may check this blog post for a reference.
 
Regards,
Yordanka
the Telerik team

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

Tags
GridView
Asked by
Richard
Top achievements
Rank 1
Answers by
Yordanka
Telerik team
Tony
Top achievements
Rank 1
Ronald
Top achievements
Rank 1
Chris
Top achievements
Rank 1
Share this question
or