GridView grouping throws ArgumentOutOfRangeException

5 posts, 0 answers
  1. Bart Reekmans
    Bart Reekmans avatar
    26 posts
    Member since:
    Mar 2010

    Posted 10 May 2011 Link to this post

    Hello,

    We just updated our telerik-controls to the latest version (2011 Q1). Now I am getting an exception when trying to use the gridview grouping.

    This is the xaml for my gridview :

    <telerik:RadGridView AutoExpandGroups="True" ShowColumnHeaders="False" 
                     ItemsSource="{Binding SelectedCategoryDataItems}"
                     CanUserFreezeColumns="False" CanUserReorderColumns="False" 
                     CanUserResizeColumns="False" 
                     EditTriggers="None" IsReadOnly="True" 
                     AutoGenerateColumns="False"
                     ActionOnLostFocus="None" RowIndicatorVisibility="Collapsed" 
                     ShowGroupPanel="False"  
                     HorizontalAlignment="Stretch" Grid.Column="1" 
                     RowStyle="{StaticResource GridItemStyle}"/>

    The SelectedCategoryDataItems property is a QueryableCollectionView. The groupdescriptor is added from the viewmodel code-behind :

    DataItems.GroupDescriptors.Add(new GroupDescriptor() { Member = "Status2" });

    When I set AutoExpandGroups = True, the following exception is immediately thrown (application doesn't start) :
     
    bij System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)
    bij System.ThrowHelper.ThrowArgumentOutOfRangeException()
    bij System.Collections.Generic.List`1.get_Item(Int32 index)
    bij System.Collections.ObjectModel.Collection`1.get_Item(Int32 index)
    bij Telerik.Windows.Controls.GridView.GridViewGroupRow.OnIsExpandedChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
    bij System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
    bij System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
    bij System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
    bij System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, OperationType operationType)
    bij System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, OperationType operationType, Boolean isInternal)
    bij System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)
    bij Telerik.Windows.Controls.GridView.GridViewDataControl.RestoreItemValue(DependencyObject container, DependencyProperty property, Object item)
    bij Telerik.Windows.Controls.GridView.GridViewDataControl.RestoreGroupPropeprties(GridViewGroupRow groupRow)
    bij Telerik.Windows.Controls.GridView.GridViewDataControl.PrepareContainerForGroupItemOverride(DependencyObject element, Object item)
    bij Telerik.Windows.Controls.GridView.BaseItemsControl.Telerik.Windows.Controls.GridView.IGeneratorHost.PrepareItemContainer(DependencyObject container, Object item)
    bij Telerik.Windows.Controls.GridView.GridViewItemContainerGenerator.System.Windows.Controls.Primitives.IItemContainerGenerator.PrepareItemContainer(DependencyObject container)
    bij Telerik.Windows.Controls.GridView.GridViewVirtualizingPanel.InsertContainer(Int32 childIndex, UIElement container, Boolean isRecycled)
    bij Telerik.Windows.Controls.GridView.GridViewVirtualizingPanel.InsertNewContainer(Int32 childIndex, UIElement container)
    bij Telerik.Windows.Controls.GridView.GridViewVirtualizingPanel.AddContainerFromGenerator(Int32 childIndex, UIElement child, Boolean newlyRealized)
    bij Telerik.Windows.Controls.GridView.GridViewVirtualizingPanel.MeasureOverride(Size constraint)
    bij System.Windows.FrameworkElement.MeasureCore(Size availableSize)
    bij System.Windows.UIElement.Measure(Size availableSize)
    bij System.Windows.ContextLayoutManager.UpdateLayout()
    bij System.Windows.ContextLayoutManager.UpdateLayoutCallback(Object arg)
    bij System.Windows.Media.MediaContext.InvokeOnRenderCallback.DoWork()
    bij System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks()
    bij System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget)
    bij System.Windows.Media.MediaContext.RenderMessageHandler(Object resizedCompositionTarget)
    bij System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter)
    bij System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
    bij System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
    bij System.Windows.Threading.DispatcherOperation.InvokeImpl()
    bij System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)
    bij System.Threading.ExecutionContext.runTryCode(Object userData)
    bij System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
    bij System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
    bij System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
    bij System.Windows.Threading.DispatcherOperation.Invoke()
    bij System.Windows.Threading.Dispatcher.ProcessQueue()
    bij System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
    bij MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
    bij MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
    bij System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter)
    bij System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
    bij System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
    bij System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Boolean isSingleParameter)
    bij System.Windows.Threading.Dispatcher.Invoke(DispatcherPriority priority, Delegate method, Object arg)
    bij MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
    bij MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
    bij System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
    bij System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
    bij System.Windows.Threading.Dispatcher.Run()
    bij System.Windows.Application.RunDispatcher(Object ignore)
    bij System.Windows.Application.RunInternal(Window window)
    bij System.Windows.Application.Run(Window window)
    bij System.Windows.Application.Run()
    bij Artemis.App.Main() in R:\WPF\Sln_Huisartsen\Sln_Huisartsen\obj\x86\Debug\App.g.cs:regel 0
    bij System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
    bij System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
    bij Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
    bij System.Threading.ThreadHelper.ThreadStart_Context(Object state)
    bij System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
    bij System.Threading.ThreadHelper.ThreadStart()

    Setting AutoExpandGroups to False gives the following exception in the output-window when I'm trying to expand a group from the UI :

    System.Windows.Data Error: 8 : Cannot save value from target back to source. BindingExpression:Path=IsExpanded; DataItem='GridViewGroupRow' (Name=''); target element is 'ToggleButton' (Name='HeaderButton'); target property is 'IsChecked' (type 'Nullable`1') ArgumentOutOfRangeException:'System.ArgumentOutOfRangeException: De index valt buiten het bereik. Deze mag niet negatief zijn en moet kleiner zijn dan de grootte van de verzameling.
    Parameternaam: index
       bij System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)
       bij System.ThrowHelper.ThrowArgumentOutOfRangeException()
       bij System.Collections.Generic.List`1.get_Item(Int32 index)
       bij System.Collections.ObjectModel.Collection`1.get_Item(Int32 index)
       bij Telerik.Windows.Controls.GridView.GridViewGroupRow.OnIsExpandedChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
       bij System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
       bij System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
       bij System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
       bij System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, OperationType operationType)
       bij System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, OperationType operationType, Boolean isInternal)
       bij System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)
       bij MS.Internal.Data.PropertyPathWorker.SetValue(Object item, Object value)
       bij MS.Internal.Data.ClrBindingWorker.UpdateValue(Object value)
       bij System.Windows.Data.BindingExpression.UpdateSource(Object value)'

    Any ideas / advice on this?

    Thanks in advance!
  2. Bart Reekmans
    Bart Reekmans avatar
    26 posts
    Member since:
    Mar 2010

    Posted 10 May 2011 Link to this post

    I managed to solve the problem. I removed the rowstyle property from the grid, and created a single column with my view as celltemplate.

    <telerik:RadGridView IsHitTestVisible="True"  AutoExpandGroups="True" ShowColumnHeaders="False" 
                     ItemsSource="{Binding DataItems, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}"
                     SelectedItem="{Binding SelectedDataItem, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}"
                     CanUserFreezeColumns="False" CanUserReorderColumns="False" 
                     CanUserResizeColumns="False" 
                     EditTriggers="None" IsReadOnly="True" 
                     AutoGenerateColumns="False"
                     ActionOnLostFocus="None" RowIndicatorVisibility="Collapsed" 
                     ShowGroupPanel="False"  
                     HorizontalAlignment="Stretch" Grid.Column="1">
                <i:Interaction.Triggers>
                    <i:EventTrigger EventName="RowActivated">
                        <bv:MapGridDoubleClickToCommand Command="{Binding Path=RowActivatedCommand}" />
                    </i:EventTrigger>
                </i:Interaction.Triggers>
                <telerik:RadGridView.Columns>
                    <telerik:GridViewColumn Width="*">
                        <telerik:GridViewColumn.CellTemplate>
                            <DataTemplate>
                                <views:PatientView/>
                            </DataTemplate>
                        </telerik:GridViewColumn.CellTemplate>
                    </telerik:GridViewColumn>
                </telerik:RadGridView.Columns>
            </telerik:RadGridView>

    After this the grouping worked.
  3. UI for WPF is Visual Studio 2017 Ready
  4. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 11 May 2011 Link to this post

    Hi Chris Verstreken,

    I am glad to see that you found the most appropriate for your scenario solution. Let us know in case you need any further assistance.
     

    All the best,
    Maya
    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
  5. Fandy Backers
    Fandy Backers avatar
    15 posts
    Member since:
    Apr 2009

    Posted 02 Dec 2011 Link to this post

    When I updated my Telerik Controls to the newest version I had a same sort of error on my RadGrid, well I think that you have the same problem with your GridView! 

    After a whole lot of debugging from scratch, i found out that you were right it has to do with 'GROUPING', so what i found out, is that i think is that at this moment the EnableLinqExpressions="False" defaults to "True"?!

    What costs me a lot of debugging, is trying to help somebody else with this problem!

    so try to add this to the radgridview: EnableLinqExpressions="False", ofcoarse it doesn't work when you are using LinQ as connection..

    I hope this helps you with your problem, when you enable the groupingstuff..

    The problem didn't rise before until i updated my Controls from 2011.2.915.35 to 2011.3.1115.35!
    just an update to get the newest skin.dll working.. and my grids with grouping didn't work anymore. It has to be a very small thing, but a big change?! .. I don't know why they changed this?


    regards,

    Fandy
  6. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 05 Dec 2011 Link to this post

    Hi,

     EnableLinqExpressions is a property of our ASP.NET grid. This thread is related to our WPF grid.

    All the best,
    Vlad
    the Telerik team

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

Back to Top
UI for WPF is Visual Studio 2017 Ready