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

[Solved] Exception thrown when cell is edited while grid is sorted

3 Answers 81 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Michael Hassinger
Top achievements
Rank 1
Michael Hassinger asked on 15 Sep 2010, 02:52 AM
I have a GridView bound to a DomainDataSource.  The DomainDataSource has a sort based on a field called StepOrder.  When I start the page and load the grid, it shows that the StepOrder column is sorted in ascending order, and I can then choose to sort the grid a different way, whichis great.

However, when I click into a cell in the StepOrder column and change the value so that it would change the order of the rows in the sort, I get a reference not set to an instance of an object error thrown.

How can I keep the grid sorted by StepOrder (assuming the user doesn't click the column headers to resort) and make sure they can safely edit the StepOrder values? 

In GridSteps_CellEditEnded, I just call ddsSteps.SubmitChanges();

Here is my XAML:

<ria:DomainDataSource x:Name="ddsSteps" QueryName="GetSteps" AutoLoad="False">

    <ria:DomainDataSource.DomainContext>
        
<ds:EngineeringContext/>

 

    </ria:DomainDataSource.DomainContext>

 

 

    <ria:DomainDataSource.SortDescriptors>

 

        <ria:SortDescriptor Direction="Ascending" PropertyPath="StepOrder" />

 

 

    </ria:DomainDataSource.SortDescriptors>

 

 

 

</ria:DomainDataSource>

 

 

 

 

 

<datagrid:RadGridView x:Name="GridSteps" IsReadOnly="False" CellEditEnded="GridSteps_CellEditEnded" ItemsSource="{Binding Data, ElementName=ddsSteps}" dragDrop:RadDragAndDropManager.AllowDrop="True" AutoGenerateColumns="False" IsFilteringAllowed="False" CanUserFreezeColumns="False" CanUserInsertRows="False" ShowGroupPanel="False">

 

    <datagrid:RadGridView.Columns>

        

<datagrid:GridViewDataColumn Header="Step Description" DataMemberBinding="{Binding StepDesc}" Width="250"/>

 

         

<datagrid:GridViewDataColumn Header="Order" DataMemberBinding="{Binding StepOrder}" Width="50"/>

 

    </datagrid:RadGridView.Columns>

<

/datagrid:RadGridView>

 

 

 

 

 

3 Answers, 1 is accepted

Sort by
0
Veselin Vasilev
Telerik team
answered on 15 Sep 2010, 04:35 PM
Hi Michael Hassinger,

I tried to reproduce the problem in a simple project, but was not able. I used the Q2 2010 assemblies.
Can you please create a sample application which replicates the issue and attach it in a new support ticket?
This will help us troubleshoot the problem locally.

Thanks

Sincerely yours,
Veselin Vasilev
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
Michael Hassinger
Top achievements
Rank 1
answered on 26 Oct 2010, 05:56 AM
I was able to get this fixed, but I'm still not sure what the problem was.

Essentially what was happening was after editing the field which contained the order of the rows, any time I tried to edit the last row, it would throw an reference not set to an instance of an object result.

For example, if the grid had

Step Description    Step Order
Design                    10
Drawing                   20
Approval                  30

And I changed a value so it would be

Drawing                 45

Any time I'd try to edit ANY field in the Approval row, it would bomb. What I did was change the CellEditEnded event handling (where I was submitting changes) to RowEditEnded. That seems to work now. Changing the step order now causes no problem, and the grid resorts itself if the values in that column warrant it.
0
Veselin Vasilev
Telerik team
answered on 28 Oct 2010, 02:06 PM
Hi Michael Hassinger,

I am glad that you have found a solution and appreciate that you share it with the community.
Thank you.

If something else pop up - let us know.

Greetings,
Veselin Vasilev
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
Michael Hassinger
Top achievements
Rank 1
Answers by
Veselin Vasilev
Telerik team
Michael Hassinger
Top achievements
Rank 1
Share this question
or