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. Image for the cookie policy date
close icon

GridGroupingControl and CurrentCell Navigation

Hello,

I am having an exception generated when attempting to navigate through cells in my GridGroupingControl. I am binding to a collection of custom defined entities, and the exception being generated is preventing proper tab or arrow key movement from one cell to another.

The problem occurs in the following scenario:

Suppose I have an object "Entity" with properties "Id" (int), "Code" (string) and "Lookup" (i.e. there is a one-to-one relationship between the "Entity" object and an object of type "Lookup"). The object "Lookup" has properties "Id" (int) and "Code" (string). The grid is defined as read-only, and I define four columns in my grid, as follows:

Column 1
Name : "EntityId"
MappingName : "Id"
HeaderText : "Id"

Column 2
Name : "EntityCode"
MappingName : "Code"
HeaderText : "Code"

Column 3
Name : "LookupId"
MappingName : "Lookup.Id" (note the "." operator)
HeaderText : "Lookup Id"

Column 4
Name : "LookupCode"
MappingName : "Lookup.Code" (note the "." operator)
HeaderText : "Lookup Code"

The exception generated is a NullReferenceException ("Object reference not set to an instance of an object") when I attempt to use the keyboard to navigate out of the columns which are defined as a two-level binding (i.e. the columns which are bound to the properties on the "Lookup" reference object). This exception occurs after the "TableControlMoveCurrentCellDirection" event, which is what brought it to my attention. The navigation does not proceed as intended due to the exception being generated.

What is causing this exception? Is "multi-level databinding" not recommended or problematic when using the GridGroupingControl? Is there an event that occurs after the "TableControlMoveCurrentCellDirection" event that can be trapped to handle the exception? I cannot determine where in the Syncfusion code the error is being generated and as such have limited debugging capabilities in that regard.

I have devised a workaround to handle multi-level binding, but it involves implementing the "QueryValue" and "SaveValue" events for all unbound columns and manually retrieving/persisting the necessary data. I would prefer to simply let the grid handle the binding for me, but if multi-level binding generates errors, I may have no choice but to implement the methods and manually handle the query/save process for all properties which are not value types on my entity objects.

Any help you can provide is appreciated. Thanks.

4 Replies

AD Administrator Syncfusion Team November 21, 2006 07:18 AM UTC

Hi John,

The StrongTypedCollection (\Syncfusion\Essential Studio\4.3.0.25\windows\Grid.Grouping.Windows\Samples\StrongTypedCollection\) browser sample demonstrates the implementation of a Custom Collection in a grouping grid. It also implements the multi-level databinding in a grid. Please try the sample and let me know if you are looking something different

Best Regards,
Haneef


AD Administrator Syncfusion Team November 21, 2006 01:03 PM UTC

Hi Haneef,

That is not quite what I am looking for. My grid is displaying a single level of data (i.e. no "flex grid" hierarchical functionality), but on the single level, I am attempting to display data from two different objects. The primary object (Object A) has a property which references another object (Object B), and I want to display properties from both A and B on the same grid level. By specifying a column mapping as "B.Property1", I can see the value of the property, but attempts to navigate off of the cell containing the text generate a NullReferenceException and prevent proper grid navigation.

Any ideas or suggestions on how to prevent/handle the exception or otherwise structure the grid, without having to implement custom query/save handlers?

Thanks for your continued assistance.

>Hi John,

The StrongTypedCollection (\Syncfusion\Essential Studio\4.3.0.25\windows\Grid.Grouping.Windows\Samples\StrongTypedCollection\) browser sample demonstrates the implementation of a Custom Collection in a grouping grid. It also implements the multi-level databinding in a grid. Please try the sample and let me know if you are looking something different

Best Regards,
Haneef


AD Administrator Syncfusion Team November 22, 2006 06:46 AM UTC

Hi John,

The attached sample demonstrates the implementation of the IBindingList for the ArrayList that is used internally. Implementing the IBindingList will require the implementation of all the members of the IBindingList, IList, ICollection and IEnumerable interfaces.It also shows data from two different objects. Please refer to the attached sample for implemeantion.

Sample: http://www.syncfusion.com/Support/user/uploads/ListGGC_b707f80c.zip

Best Regards,
Haneef


AD Administrator Syncfusion Team November 22, 2006 01:53 PM UTC

Hi Haneef,

That sample gives me the information I need.

In my code, I was programmatically generating my columns, including defining the mapping name and column names for all of the properties to be displayed. I found that by defining a mapping name as

"ChildObject.Property1"

would result in errors. After examining your sample, and modifying the mapping name of the column to

"ChildObject_Property1"

the exception I was encountering disappeared. Thanks for your assistance!

>Hi John,

The attached sample demonstrates the implementation of the IBindingList for the ArrayList that is used internally. Implementing the IBindingList will require the implementation of all the members of the IBindingList, IList, ICollection and IEnumerable interfaces.It also shows data from two different objects. Please refer to the attached sample for implemeantion.

Sample: http://www.syncfusion.com/Support/user/uploads/ListGGC_b707f80c.zip

Best Regards,
Haneef

Loader.
Live Chat Icon For mobile
Up arrow icon