We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

ExpandAllGroups throws NullReferenceException

Thread ID:





98797 Mar 31,2011 10:37 AM UTC Apr 7,2011 06:58 AM UTC WPF 3
Tags: GridControl
Asked On March 31, 2011 10:37 AM UTC

I'm using GridDataCotrol with groups. Every time I insert new data to it I want groups to be expanded. So I've found myGrid.Model.Table.ExpandAllGroups() method. But It throws NullReferenceException ({"Object reference not set to an instance of an object."}).
Here's some VS exception snapshot:
InnerException is null,
Source is Syncfusion.Grid.Wpf

Does anyone know what may be the issue here?


Manikandan [Syncfusion]
Replied On April 1, 2011 01:50 PM UTC

Hi Flashman,

Thanks for using Syncfusion products

We have analyzed the reported issue with our samples , however, we do not get any exception while inserting new data, it
works fine and all groups are expanded. Could you please check with this sample and video from the following location.

Sample : http://www.syncfusion.com/uploads/redirect.aspx?&team=support&file=Grouping_I1550148488.zip

Video : http://www.syncfusion.com/uploads/redirect.aspx?&team=support&file=Group-1955870816.zip

In order to resolve the issue further, could you please share a simple sample or the steps to replicate this issue?

Please let us know if you have any further queries.


Replied On April 6, 2011 08:35 AM UTC

Thanks for the reply and example with video.

I should better examine and describe the problem. I was unable to expand the groups via code. To be exact if I had collapsed groups in datagrid and I used let's say a button to call the datagrid.Model.Table.ExpandAllGroups() it worked ok. But in my situation it threw that exception. More If I had somewhere in form constructor this code it threw the exception TargetInvocationException.
I mean for example if you use at the end of the contructor in MainWindow.xaml.cs this:
dataGrid1.ItemsSource = new Product();
and detele ItemsSource="..." in xaml

So to get rid of those problems I'm now using this code before asking for grid expanding:
if (u_dataGrid1.Model.TableProperties != null)

I'm not sure what was it about.. but now it works well.

Manikandan [Syncfusion]
Replied On April 7, 2011 06:58 AM UTC

Hi Jakub,

Thanks for your update.

Normally the ItemSource gets loaded to the grid once after the Model loaded. You can achieve your requirement by calling the ExpandAllGroups() method in grid Loaded event.

Please refer the below code snippet:

this.dataGrid1.Loaded += new RoutedEventHandler(dataGrid1_Loaded);

void dataGrid1_Loaded(object sender, RoutedEventArgs e)

We have prepared a sample based on this and you can find the sample from the following location:

Sample: http://www.syncfusion.com/uploads/redirect.aspx?&team=support&file=Grouping_I65375484.zip

Please let us know if you have any queries.



This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon