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

Error when dragging group item set by LoadLayout

6 Answers 144 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Grant
Top achievements
Rank 1
Grant asked on 04 Aug 2015, 04:48 PM

We found a very strange error that occurs if someone tries to drag a grouped column and the mouse is on the X to close the group item.

After a column is grouped, you can drag it out of the group area to ungroup, or drag it to a different location to change the group hierarchy. This works fine as long as you don't happen to grab the group by the "X" in the group area. If you place the mouse pointer on the X hold the left mouse button down, moving the mouse at all throws an object reference error. The call stack is shown below.

To make the problem even more bizarre, this doesn't occur if the user manually ​groups the column. It only seems to occur if we set the grouping in code. We allow users to save their desired display settings. We save them in an XML file and reload them using the LoadLayout and SaveLayout methods. The XML that we are loading with LoadLayout is shown below.

Error call stack:

System.NullReferenceException: Object reference not set to an instance of an object.
   at Telerik.WinControls.UI.GridRowBehavior.ExtendSelectionUp(GridTableElement tableElement, Rectangle viewportBounds, Point location)
   at Telerik.WinControls.UI.GridRowBehavior.ExtendSelectionOnMouseMove(GridTableElement tableElement, Rectangle viewportBounds, Point location)
   at Telerik.WinControls.UI.GridRowBehavior.scrollTimer_Tick(Object sender, EventArgs e)
   at System.Windows.Forms.Timer.OnTick(EventArgs e)
   at System.Windows.Forms.Timer.TimerNativeWindow.WndProc(Message_ m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) 

LoadLayout XML:

<RadGridView GroupExpandAnimationType="Fade" ReadOnly="True" NewRowEnterKeyMode="None" CausesValidation="False" BackColor="Transparent" ForeColor="ControlText" Font="Microsoft Sans Serif, 8.25pt" Cursor="Default" RightToLeft="No" TabIndex="0" ImeMode="NoControl">
  <MasterTemplate MultiSelect="True" AllowRowResize="False" Caption="test caption" EnableFiltering="True" ShowGroupedColumns="True" ReadOnly="True" AutoGenerateColumns="False" AutoExpandGroups="True" ShowRowHeaderColumn="False">
    <Columns>
      <Telerik.WinControls.UI.GridViewTextBoxColumn FieldName="pkTask" Name="pkTask" VisibleInColumnChooser="False" IsVisible="False" AllowSort="False" AllowGroup="False" AllowResize="False" HeaderText="pkTask" />
      <Telerik.WinControls.UI.GridViewImageColumn DataType="System.Byte[]" AllowFiltering="False" TextImageRelation="ImageAboveText" Width="17" FieldName="PriorityImage" Name="PriorityImage" VisibleInColumnChooser="False" IsVisible="True" IsPinned="True" PinPosition="Left" AllowSort="False" AllowResize="False" AllowHide="False" HeaderText="" />
      <Telerik.WinControls.UI.GridViewImageColumn DataType="System.Byte[]" AllowFiltering="False" Width="27" FieldName="ReadImage" Name="ReadImage" VisibleInColumnChooser="False" IsVisible="True" IsPinned="True" PinPosition="Left" AllowSort="False" AllowResize="False" AllowHide="False" HeaderText="" />
      <Telerik.WinControls.UI.GridViewImageColumn DataType="System.Byte[]" AllowFiltering="False" TextImageRelation="ImageAboveText" Width="27" FieldName="NoteImage" Name="NoteImage" IsVisible="True" IsPinned="True" PinPosition="Left" AllowSort="False" AllowResize="False" AllowHide="False" HeaderText="" />
      <Telerik.WinControls.UI.GridViewTextBoxColumn Width="77" FieldName="TaskNumber" Name="TaskNumber" IsVisible="True" AllowGroup="False" HeaderText="Task Num" />
      <Telerik.WinControls.UI.GridViewTextBoxColumn FieldName="QueueName" Name="QueueName" IsVisible="False" HeaderText="Queue" />
      <Telerik.WinControls.UI.GridViewTextBoxColumn Width="121" FieldName="AssignedToName" Name="AssignedToName" IsVisible="False" ReadOnly="True" HeaderText="Assigned To" />
      <Telerik.WinControls.UI.GridViewTextBoxColumn Width="352" FieldName="TaskDescription" Name="TaskDescription" IsVisible="True" AllowGroup="False" HeaderText="Task Description" />
      <Telerik.WinControls.UI.GridViewTextBoxColumn Width="66" FieldName="TaskStatusDescription" Name="TaskStatusDescription" IsVisible="True" HeaderText="Status" />
      <Telerik.WinControls.UI.GridViewTextBoxColumn FieldName="TaskStatusReason" Name="TaskStatusReason" IsVisible="False" HeaderText="Reason" />
      <Telerik.WinControls.UI.GridViewTextBoxColumn Width="114" FieldName="TaskTypeDescription" Name="TaskTypeDescription" IsVisible="True" HeaderText="Type" />
      <Telerik.WinControls.UI.GridViewDateTimeColumn Format="Long" Width="126" FieldName="DueDate" Name="DueDate" IsVisible="True" HeaderText="Date Due" />
      <Telerik.WinControls.UI.GridViewTextBoxColumn AllowFiltering="False" Width="77" FieldName="DueCountdown" Name="DueCountdown" IsVisible="True" AllowSort="False" AllowGroup="False" HeaderText="Due" DisableHTMLRendering="False" />
      <Telerik.WinControls.UI.GridViewTextBoxColumn Width="77" FieldName="PriorityDescription" Name="PriorityDescription" IsVisible="True" HeaderText="Priority" />
      <Telerik.WinControls.UI.GridViewTextBoxColumn Width="182" FieldName="ClientInfo" Name="ClientInfo" IsVisible="True" HeaderText="Member Info" />
      <Telerik.WinControls.UI.GridViewDateTimeColumn Format="Long" Width="118" FieldName="CompleteDate" Name="CompleteDate" IsVisible="False" AllowGroup="False" HeaderText="Date Completed" />
      <Telerik.WinControls.UI.GridViewDecimalColumn Width="103" FieldName="TaskCreateUser" Name="TaskCreateUser" VisibleInColumnChooser="False" IsVisible="False" HeaderText="TaskCreateUser" />
      <Telerik.WinControls.UI.GridViewDecimalColumn FieldName="fkrefTaskType" Name="fkrefTaskType" VisibleInColumnChooser="False" IsVisible="False" AllowSort="False" AllowGroup="False" AllowResize="False" HeaderText="fkrefTaskType" />
      <Telerik.WinControls.UI.GridViewDecimalColumn FieldName="fkrefTaskStatus" Name="fkrefTaskStatus" VisibleInColumnChooser="False" IsVisible="False" AllowSort="False" AllowGroup="False" AllowResize="False" HeaderText="fkrefTaskStatus" />
      <Telerik.WinControls.UI.GridViewDecimalColumn DataType="System.Int32" FieldName="PriorityCode" Name="PriorityCode" VisibleInColumnChooser="False" IsVisible="False" AllowGroup="False" AllowResize="False" HeaderText="PriorityCode" />
      <Telerik.WinControls.UI.GridViewCheckBoxColumn MinWidth="20" FieldName="GroupTask" Name="GroupTask" VisibleInColumnChooser="False" IsVisible="False" AllowSort="False" AllowGroup="False" AllowResize="False" HeaderText="GroupTask" />
      <Telerik.WinControls.UI.GridViewDateTimeColumn Format="Long" FieldName="StartDate" Name="StartDate" VisibleInColumnChooser="False" IsVisible="False" HeaderText="StartDate" />
      <Telerik.WinControls.UI.GridViewTextBoxColumn Width="121" FieldName="StateCaseNumber" Name="StateCaseNumber" IsVisible="True" HeaderText="State Case Number" />
      <Telerik.WinControls.UI.GridViewTextBoxColumn Width="123" FieldName="AssignedByName" Name="AssignedByName" IsVisible="False" ReadOnly="True" HeaderText="Assigned By" />
      <Telerik.WinControls.UI.GridViewCheckBoxColumn MinWidth="20" FieldName="UserRead" Name="UserRead" VisibleInColumnChooser="False" IsVisible="False" AllowSort="False" AllowGroup="False" AllowResize="False" HeaderText="UserRead" />
      <Telerik.WinControls.UI.GridViewTextBoxColumn FieldName="pkTaskAssignment" Name="pkTaskAssignment" VisibleInColumnChooser="False" IsVisible="False" AllowSort="False" AllowGroup="False" AllowResize="False" HeaderText="pkTaskAssignment" />
      <Telerik.WinControls.UI.GridViewTextBoxColumn FieldName="TaskSource" Name="TaskSource" VisibleInColumnChooser="False" IsVisible="False" AllowSort="False" AllowGroup="False" ReadOnly="True" AllowResize="False" HeaderText="TaskSource" />
      <Telerik.WinControls.UI.GridViewTextBoxColumn Width="111" FieldName="SourceModuleName" Name="SourceModuleName" IsVisible="True" ReadOnly="True" HeaderText="Source" />
      <Telerik.WinControls.UI.GridViewTextBoxColumn Width="91" FieldName="TaskOriginDescription" Name="TaskOriginDescription" IsVisible="False" HeaderText="Task Origin" />
      <Telerik.WinControls.UI.GridViewTextBoxColumn DataType="System.Decimal" FieldName="fkApplicationUserAssignedTo" Name="fkApplicationUserAssignedTo" VisibleInColumnChooser="False" IsVisible="False" HeaderText="fkApplicationUserAssignedTo" />
      <Telerik.WinControls.UI.GridViewDateTimeColumn Format="Long" Width="160" FieldName="CreateDate" Name="CreateDate" SortOrder="Descending" IsVisible="True" AllowGroup="False" HeaderText="Date Created" />
      <Telerik.WinControls.UI.GridViewTextBoxColumn FieldName="CountyCode" Name="CountyCode" VisibleInColumnChooser="False" IsVisible="False" AllowGroup="False" ReadOnly="True" HeaderText="County Code" />
      <Telerik.WinControls.UI.GridViewDateTimeColumn Format="Long" FieldName="DueDateOnly" Name="DueDateOnly" VisibleInColumnChooser="False" IsVisible="False" HeaderText="Due Date" />
      <Telerik.WinControls.UI.GridViewDateTimeColumn Format="Long" Width="142" FieldName="AssignmentCreateDate" Name="AssignmentCreateDate" EnableExpressionEditor="False" IsVisible="False" AllowGroup="False" HeaderText="Date Assigned" />
      <Telerik.WinControls.UI.GridViewCheckBoxColumn MinWidth="20" FieldName="UserReadNote" Name="UserReadNote" EnableExpressionEditor="False" VisibleInColumnChooser="False" IsVisible="False" AllowSort="False" AllowGroup="False" AllowResize="False" HeaderText="UserReadNote" />
      <Telerik.WinControls.UI.GridViewTextBoxColumn DataType="System.Int32" FieldName="TaskNoteLength" Name="TaskNoteLength" EnableExpressionEditor="False" VisibleInColumnChooser="False" IsVisible="False" AllowSort="False" AllowGroup="False" AllowResize="False" HeaderText="TaskNoteLength" />
    </Columns>
    <SortDescriptors>
      <Telerik.WinControls.Data.SortDescriptor PropertyName="CreateDate" Direction="Descending" />
    </SortDescriptors>
    <GroupDescriptors>
      <Telerik.WinControls.Data.GroupDescriptor>
        <GroupNames>
          <Telerik.WinControls.Data.SortDescriptor PropertyName="TaskTypeDescription" />
        </GroupNames>
      </Telerik.WinControls.Data.GroupDescriptor>
    </GroupDescriptors>

    <ViewDefinition xsi:type="Telerik.WinControls.UI.TableViewDefinition" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" />
  </MasterTemplate>
  <ContextMenuStrip Name="cmMenu">
    <Items>
      <System.Windows.Forms.ToolStripMenuItem ShortcutKeys="Ctrl+F1" Name="" Size="345, 22" Tag="Assigned" Text="Change Task(s) Status To Assigned">
        <Image xsi:type="System.Drawing.Bitmap" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" />
      </System.Windows.Forms.ToolStripMenuItem>
      <System.Windows.Forms.ToolStripMenuItem ShortcutKeys="Ctrl+F2" Name="" Size="345, 22" Tag="InProgress" Text="Change Task(s) Status To In Progress">
        <Image xsi:type="System.Drawing.Bitmap" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" />
      </System.Windows.Forms.ToolStripMenuItem>
      <System.Windows.Forms.ToolStripMenuItem ShortcutKeys="Ctrl+F3" Name="" Size="345, 22" Tag="Complete" Text="Complete Task(s)">
        <Image xsi:type="System.Drawing.Bitmap" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" />
      </System.Windows.Forms.ToolStripMenuItem>
      <System.Windows.Forms.ToolStripMenuItem ShortcutKeys="Ctrl+D" Name="" Size="345, 22" Tag="Delete" Text="Delete Task(s)">
        <Image xsi:type="System.Drawing.Bitmap" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" />
      </System.Windows.Forms.ToolStripMenuItem>
      <System.Windows.Forms.ToolStripMenuItem ShortcutKeys="Ctrl+R" Name="" Size="345, 22" Tag="MarkRead" Text="Mark Task(s) Read">
        <Image xsi:type="System.Drawing.Bitmap" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" />
      </System.Windows.Forms.ToolStripMenuItem>
      <System.Windows.Forms.ToolStripMenuItem ShortcutKeys="Ctrl+U" Name="" Size="345, 22" Tag="MarkUnread" Text="Mark Task(s) Un-Read">
        <Image xsi:type="System.Drawing.Bitmap" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" />
      </System.Windows.Forms.ToolStripMenuItem>
      <System.Windows.Forms.ToolStripMenuItem ShortcutKeys="Ctrl+F7" Name="" Size="345, 22" Tag="AssgnFollowUpMarkAsComplete" Text="Assign Follow Up Date (Mark as Complete)">
        <Image xsi:type="System.Drawing.Bitmap" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" />
      </System.Windows.Forms.ToolStripMenuItem>
      <System.Windows.Forms.ToolStripMenuItem ShortcutKeys="Ctrl+F5" Name="" Size="345, 22" Tag="Reassign" Text="Reassign Task(s)">
        <Image xsi:type="System.Drawing.Bitmap" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" />
      </System.Windows.Forms.ToolStripMenuItem>
      <System.Windows.Forms.ToolStripMenuItem ShortcutKeys="Ctrl+F4" Name="" Size="345, 22" Tag="Copy" Text="Copy Task">
        <Image xsi:type="System.Drawing.Bitmap" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" />
      </System.Windows.Forms.ToolStripMenuItem>
      <System.Windows.Forms.ToolStripMenuItem ShortcutKeys="Ctrl+F6" Name="" Size="345, 22" Tag="ViewTaskHistory" Text="View Task History">
        <Image xsi:type="System.Drawing.Bitmap" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" />
      </System.Windows.Forms.ToolStripMenuItem>
      <System.Windows.Forms.ToolStripSeparator Name="" Size="342, 6" Tag="None" />
      <System.Windows.Forms.ToolStripMenuItem ShortcutKeys="Ctrl+N" Name="" Size="345, 22" Tag="NewTask" Text="Create New Task">
        <Image xsi:type="System.Drawing.Bitmap" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" />
      </System.Windows.Forms.ToolStripMenuItem>
      <System.Windows.Forms.ToolStripMenuItem ShortcutKeys="Ctrl+L" Name="" Size="345, 22" Tag="SelectColumns" Text="Select Columns">
        <Image xsi:type="System.Drawing.Bitmap" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" />
      </System.Windows.Forms.ToolStripMenuItem>
      <System.Windows.Forms.ToolStripMenuItem ShortcutKeys="Ctrl+A" Name="" Size="345, 22" Tag="SelectAllTasks" Text="Select All">
        <Image xsi:type="System.Drawing.Bitmap" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" />
      </System.Windows.Forms.ToolStripMenuItem>
      <System.Windows.Forms.ToolStripMenuItem ShortcutKeys="Ctrl+F8" Name="" Size="345, 22" Tag="EraseFilter" Text="Clear Filters">
        <Image xsi:type="System.Drawing.Bitmap" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" />
      </System.Windows.Forms.ToolStripMenuItem>
      <System.Windows.Forms.ToolStripMenuItem ShortcutKeys="Ctrl+F12" Name="" Size="345, 22" Tag="ExportTaskList" Text="Export Tasks List">
        <Image xsi:type="System.Drawing.Bitmap" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" />
      </System.Windows.Forms.ToolStripMenuItem>
      <System.Windows.Forms.ToolStripMenuItem ShortcutKeys="Ctrl+P" Name="" Size="345, 22" Tag="PrintTaskList" Text="Print Tasks List">
        <Image xsi:type="System.Drawing.Bitmap" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" />
      </System.Windows.Forms.ToolStripMenuItem>
    </Items>
  </ContextMenuStrip>
</RadGridView>

6 Answers, 1 is accepted

Sort by
0
Grant
Top achievements
Rank 1
answered on 05 Aug 2015, 03:06 PM

I have an update on this problem. The problem doesn't appear to be related to saved settings. It appears to be related to the data in the grid, although I haven't found the exact difference yet.

The user having the problem had about 1,400 rows displayed, and the user not having the problem had far fewer (less than 10). I'm still investigating to find out which data might be causing the issue.

0
Grant
Top achievements
Rank 1
answered on 05 Aug 2015, 05:45 PM

I found a more accurate way to describe the problem. It has nothing to do with setting groups in code vs. setting manually. Here is how to reproduce the problem:

1. Load a grid with enough rows to make scrolling necessary to see the bottom row.
2. Drag a column header into the group area.
3. Make sure the vertical scroll bar is all the way to the top.
4. Put the mouse on the "X" of the group descriptor. Hold the left mouse button and move the mouse. Nothing will happen.
5. Move the vertical scroll bar down. It doesn't matter if you scroll all the way to the end or just barely move the vertical scroll bar, as long as it isn't all the way to the top.
6. Repeat step 4, holding and dragging the group descriptor "X." An object reference error will occur. 

That's about as simple as I can make it. Hopefully someone can tell me an override or something that I can use to fix this. We just upgraded to 2015Q2 SP1 and we are ready to release a new version of our application. Right now this is the only thing holding us up.

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 06 Aug 2015, 09:50 AM
Hello Grant,

Thank you for writing.
 
I confirm that it is an issue with RadGridView. I have logged it in our feedback portal. You can track its progress, subscribe for status changes and add your vote/comment to it on the following link - feedback item.

I have also updated your Telerik points.

Currently, the possible solution that I can suggest is to use a custom row behavior:
public Form1()
{
    InitializeComponent();
 
    LoadData();
     
    //register the custom row  behavior
    BaseGridBehavior gridBehavior = rgvTest.GridBehavior as BaseGridBehavior;
    gridBehavior.UnregisterBehavior(typeof(GridViewDataRowInfo));
    gridBehavior.RegisterBehavior(typeof(GridViewDataRowInfo), new CustomGridDataRowBehavior());
}
 
public class CustomGridDataRowBehavior : GridDataRowBehavior
{
    public CustomGridDataRowBehavior()
    {
        typeof(GridRowBehavior).GetField("orderedRows", System.Reflection.BindingFlags.NonPublic |
                                                        System.Reflection.BindingFlags.Instance).SetValue(this, new List<GridViewRowInfo>()) ;
    }
 
    public override bool OnMouseUp(MouseEventArgs e)
    {
        bool result = base.OnMouseUp(e);             
        typeof(GridRowBehavior).GetField("orderedRows", System.Reflection.BindingFlags.NonPublic |
                                                        System.Reflection.BindingFlags.Instance).SetValue(this, new List<GridViewRowInfo>()) ;
        return result; 
    }
}

I hope this information helps. Should you have further questions I would be glad to help.
 
Regards,

Dess
Telerik
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 Feedback Portal and vote to affect the priority of the items
0
George
Top achievements
Rank 1
answered on 05 Oct 2015, 11:12 AM

Hello,
 I am having the same error but not by the same cause (or this is what I have been told by my customers, they were not using grouping at the time of the error) and I haven't managed to replicate the exact cause yet.

Anyway I tried to implement the solution above in case the error would be fixed (or the information I had from the client was false and this was the cause), but I cannot make it work.
What could be wrong?

Also I am already using a custom grid behavior class that inherits from BaseGridBehavior and I set it to the grid like this:
grid.GridBehavior = New CustomGridBehavior()

How can I implement this fix and keep my CustomGridBehavior class as well?
PS. I disabled ​my CustomGridBehavior when I was trying to implement the CustomGridDataRowBehavior, so this is not the reason it did not work.

0
George
Top achievements
Rank 1
answered on 05 Oct 2015, 02:34 PM

Hello again,

I noticed that when I have AutoExpandRows property set to false AND I expand a single row,

OR

I have AutoExpandRows property set to ​true AND ​I collapse a single row

(with the previous steps as well, enough rows for a scrollbar to appear and the bar not being on the top)
the error still occurs (with custom row behavior fix).

Also I set up a simple project with code provided by Dess in the feedback portal and AutoExpandRows does not seem to make any difference when the custom row behavior fix is applied.

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 07 Oct 2015, 02:22 PM
Hello George,

Thank you for writing.

Firstly, I would like to note that the issue was addressed in Q3 2015 as it is marked in the referred feedback item.

Тhe provided information is not enough for me to replicate the issue locally. Without reproducing the problem on our end, we can make only conjectures what is causing the exception. That is why we would kindly ask you to provide your project where the issue is reproducible. Feel free to open a support ticket where attachments are allowed.

RadGridView manages user mouse and keyboard input over its rows by GridRowBehavior. Depending on the row type, RadGridView introduces different behaviors. Since, you replace the default BaseGridBehavior, but the workaround registers а custom GridDataRowBehavior, you can have both of the implemented functionalities. You can refer to the GridView >> Row behaviors help article for additional information.

As to the last question, I suppose that you mean the RadGridView.AutoExpandGroups property as RadGridView does not offer AutoExpandRows property in 2015.2 728 version. Following the provided information, I was unable to reproduce the exception with the applied workaround. Please refer to the attached gif file illustrating the steps that I perform. Am I missing something? Could you please specify the exact steps how to reproduce the problem?

I am looking forward to your reply. 

Regards,
Dess
Telerik
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 Feedback Portal and vote to affect the priority of the items
Tags
GridView
Asked by
Grant
Top achievements
Rank 1
Answers by
Grant
Top achievements
Rank 1
Dess | Tech Support Engineer, Principal
Telerik team
George
Top achievements
Rank 1
Share this question
or