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

Exception deep in telerik code when entering value and pressing enter

4 Answers 139 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Anders
Top achievements
Rank 1
Anders asked on 28 Jan 2012, 11:47 AM
When editing a cell and pressing Enter I get exception below. Of course I might do something that most people don't but I can't really see what it should be. The exception is rather specific below -- would you consider handling this situation with a bit more information to the developer? I'm available for trying out unofficial builds if that could be helpful for you.

I'm currently on the latest release.

Thanks,
Anders, Denmark

System.NullReferenceException was unhandled
  Message=Object reference not set to an instance of an object.
  Source=Telerik.Windows.Controls.GridView
  StackTrace:
       at Telerik.Windows.Controls.GridView.GridViewCell.SetCellElement() in c:\TB\117\WPF_Scrum\Release_WPF\Sources\Development\Controls\GridView\GridView\GridView\Cells\GridViewCell.cs:line 508
       at Telerik.Windows.Controls.GridView.GridViewCell.HideEditor() in c:\TB\117\WPF_Scrum\Release_WPF\Sources\Development\Controls\GridView\GridView\GridView\Cells\GridViewCell.cs:line 744
       at Telerik.Windows.Controls.GridView.GridViewCell.ToggleEditor() in c:\TB\117\WPF_Scrum\Release_WPF\Sources\Development\Controls\GridView\GridView\GridView\Cells\GridViewCell.cs:line 1057
       at Telerik.Windows.Controls.GridView.GridViewDataControl.OnCellEditModeChanged(GridViewCell cell, Boolean newIsInEditMode) in c:\TB\117\WPF_Scrum\Release_WPF\Sources\Development\Controls\GridView\GridView\GridView\GridViewDataControl.Editing.cs:line 396
       at Telerik.Windows.Controls.GridView.GridViewCell.IsInEditModeChanged(DependencyObject target, DependencyPropertyChangedEventArgs e) in c:\TB\117\WPF_Scrum\Release_WPF\Sources\Development\Controls\GridView\GridView\GridView\Cells\GridViewCell.cs:line 1045
       at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
       at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
       at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
       at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)
       at System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType, Boolean isInternal)
       at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)
       at Telerik.Windows.Controls.GridView.GridViewCell.set_IsInEditMode(Boolean value) in c:\TB\117\WPF_Scrum\Release_WPF\Sources\Development\Controls\GridView\GridView\GridView\Cells\GridViewCell.cs:line 305
       at Telerik.Windows.Controls.GridView.GridViewCell.RaiseCellEditEndedEvent(GridViewEditAction editAction) in c:\TB\117\WPF_Scrum\Release_WPF\Sources\Development\Controls\GridView\GridView\GridView\Cells\GridViewCell.cs:line 1156
       at Telerik.Windows.Controls.GridView.GridViewDataControl.PerformCellEditEnded(GridViewCell currentCell) in c:\TB\117\WPF_Scrum\Release_WPF\Sources\Development\Controls\GridView\GridView\GridView\GridViewDataControl.Editing.cs:line 108
       at Telerik.Windows.Controls.GridView.GridViewDataControl.CommitCellEdit(GridViewCell currentCell, Boolean isLeavingRow) in c:\TB\117\WPF_Scrum\Release_WPF\Sources\Development\Controls\GridView\GridView\GridView\GridViewDataControl.Editing.cs:line 69
       at Telerik.Windows.Controls.GridView.GridViewDataControl.CommitEdit() in c:\TB\117\WPF_Scrum\Release_WPF\Sources\Development\Controls\GridView\GridView\GridView\GridViewDataControl.Editing.cs:line 1011
       at Telerik.Windows.Controls.GridView.GridViewDataControl.OnCommitEditCommand(Object sender, ExecutedRoutedEventArgs e) in c:\TB\117\WPF_Scrum\Release_WPF\Sources\Development\Controls\GridView\GridView\GridView\GridViewDataControl.Commands.cs:line 289
       at System.Windows.Input.CommandBinding.OnExecuted(Object sender, ExecutedRoutedEventArgs e)
       at System.Windows.Input.CommandManager.ExecuteCommandBinding(Object sender, ExecutedRoutedEventArgs e, CommandBinding commandBinding)
       at System.Windows.Input.CommandManager.FindCommandBinding(CommandBindingCollection commandBindings, Object sender, RoutedEventArgs e, ICommand command, Boolean execute)
       at System.Windows.Input.CommandManager.FindCommandBinding(Object sender, RoutedEventArgs e, ICommand command, Boolean execute)
       at System.Windows.Input.CommandManager.OnExecuted(Object sender, ExecutedRoutedEventArgs e)
       at System.Windows.UIElement.OnExecutedThunk(Object sender, ExecutedRoutedEventArgs e)
       at System.Windows.Input.ExecutedRoutedEventArgs.InvokeEventHandler(Delegate genericHandler, Object target)
       at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
       at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
       at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
       at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
       at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)
       at System.Windows.Input.RoutedCommand.ExecuteImpl(Object parameter, IInputElement target, Boolean userInitiated)
       at System.Windows.Input.RoutedCommand.Execute(Object parameter, IInputElement target)
       at Telerik.Windows.Controls.GridView.GridViewDataControl.ExecutePendingCommand() in c:\TB\117\WPF_Scrum\Release_WPF\Sources\Development\Controls\GridView\GridView\GridView\GridViewDataControl.Commands.cs:line 65
       at Telerik.Windows.Controls.GridView.GridViewDataControl.PendAndExecuteCommands(KeyEventArgs e) in c:\TB\117\WPF_Scrum\Release_WPF\Sources\Development\Controls\GridView\GridView\GridView\GridViewDataControl.cs:line 4112
       at Telerik.Windows.Controls.GridView.GridViewDataControl.OnKeyDown(KeyEventArgs e) in c:\TB\117\WPF_Scrum\Release_WPF\Sources\Development\Controls\GridView\GridView\GridView\GridViewDataControl.cs:line 4085
       at System.Windows.UIElement.OnKeyDownThunk(Object sender, KeyEventArgs e)
       at System.Windows.Input.KeyEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
       at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
       at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
       at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
       at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
       at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
       at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)
       at System.Windows.Input.InputManager.ProcessStagingArea()
       at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
       at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
       at System.Windows.Interop.HwndKeyboardInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawKeyboardActions actions, Int32 scanCode, Boolean isExtendedKey, Boolean isSystemKey, Int32 virtualKey)
       at System.Windows.Interop.HwndKeyboardInputProvider.ProcessKeyAction(MSG& msg, Boolean& handled)
       at System.Windows.Interop.HwndSource.CriticalTranslateAccelerator(MSG& msg, ModifierKeys modifiers)
       at System.Windows.Interop.HwndSource.OnPreprocessMessage(Object param)
       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)
       at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
       at System.Windows.Interop.HwndSource.OnPreprocessMessageThunk(MSG& msg, Boolean& handled)
       at System.Windows.Interop.HwndSource.WeakEventPreprocessMessage.OnPreprocessMessage(MSG& msg, Boolean& handled)
       at System.Windows.Interop.ComponentDispatcherThread.RaiseThreadMessage(MSG& msg)
       at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
       at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
       at System.Windows.Application.RunDispatcher(Object ignore)
       at System.Windows.Application.RunInternal(Window window)
       at System.Windows.Application.Run(Window window)
       at System.Windows.Application.Run()
       at Rap1D.Rap1D_WPF.App.Main() in C:\SVN\Rap1DGui\trunk\src\Rap1D_WPF\obj\x86\Debug\App.g.cs:line 0
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at System.AppDomain.nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at System.Runtime.Hosting.ManifestRunner.Run(Boolean checkAptModel)
       at System.Runtime.Hosting.ManifestRunner.ExecuteAsAssembly()
       at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext, String[] activationCustomData)
       at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext)
       at System.Activator.CreateInstance(ActivationContext activationContext)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssemblyDebugInZone()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException:

4 Answers, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 31 Jan 2012, 08:08 AM
Hello,

We will investigate what is causing this exception, but we will need a little bit more information. Would you please confirm the exact version of the RadControls that you use? Do you still get this exception with the latest internal build? Was there a previous version of the controls that have worked fine? How is your column bound, is there anything specific with the value of this cell?

Greetings,
Didie
the Telerik team

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

0
Anders
Top achievements
Rank 1
answered on 31 Jan 2012, 10:26 AM
Hi, Thanks for looking into this...

Telerik.Windows.Controls.GridView: Version=2011.3.1220.40 (as checked through reference in my WPF project in VS. Good enough?)

Latest internal build? Haven't tried that, but will. More to follow.

It has worked with previous builds, but I can't tell for sure that the cause of the break was upgrading telerik controls. We are currently working intensively on the project and the chain of events firing when changing a value in the grid has certainly changed...

Binding (It's set up through a chain of calls, hopefully readable. I've selected the lines believed to be relevant):
        var gridViewDataColumn = GetGridViewDataColumn(qSpecificationModeDataType,parName,def.GuiName);
        gridView.Columns.Add(gridViewDataColumn);
 
private GridViewDataColumn GetGridViewDataColumn(CurveSetFlowSpecification qSpecificationModeDataType,
                                                 string parName, string header)
{
    var dataMemberBinding = _dataMemberBindingProvider
        .GetDataMemberBinding(parName, qSpecificationModeDataType);
    var isReadOnly = _columnReadabilityProvider
        .GetIsReadOnly(parName, qSpecificationModeDataType);
 
    return new GridViewDataColumn
               {
                   ...,
                   DataMemberBinding = dataMemberBinding,
                   IsReadOnly = isReadOnly
               };
}
 
public Binding GetDataMemberBinding(string parName, CurveSetFlowSpecification qSpecificationModeDataType)
{
    var dataMemberBinding = new Binding(parName);
    var isReadOnly = _columnReadabilityProvider.GetIsReadOnly(parName, qSpecificationModeDataType);
 
    if (isReadOnly)
    {
        dataMemberBinding.Mode = BindingMode.OneWay;
    }
 
    return dataMemberBinding;
}
0
Dimitrina
Telerik team
answered on 01 Feb 2012, 09:45 AM
Hello,

 What is the behaviour if you set the IsReadOnly to "True" directly?

Greetings,
Didie
the Telerik team

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

0
Anders
Top achievements
Rank 1
answered on 02 Feb 2012, 02:06 PM
I've solved the problem -- changes to the underlying viewmodel needs to spark a change in which columns are readonly and which are not. I did this by recreating the columns of the grid -- also when changing a value in grid --, which most likely cased the problem.

In my case however, the actual values in grid does not change the readonly-state of columns; only comboboxes above the grid (mapped to other properties on the view model) does this.

I made my column refresh a bit more specific and the problem is gone.

I can see how this was unfairly shooting the horse under the galopping telerik rider, but still : Some better feedback when exceptions happen could save some debugging time...

Thanks for looking into it!

Anders, Denmark
Tags
GridView
Asked by
Anders
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Anders
Top achievements
Rank 1
Share this question
or