Declined
Last Updated: 28 Nov 2022 14:59 by Teddy
Teddy
Created on: 18 Nov 2022 20:27
Category: UI for .NET MAUI
Type: Bug Report
0
Null object in PropertyName throws a NullReferenceException

I'm getting a NullReferenceException when trying to display a RadDataGrid that has a column where one of the objects in the PropertyName "chain" is null. For example, in your Columns -> Columns Overview section of your sample SDK browser (SDKBrowserMaui.Examples.DataGridControl.ColumnsCategory.ColumnsExample.Columns.xaml) the data grid is bound to a list of Clubs. If you add this code to Club (With nothing else. Keep Manager null):

private Person _manager;
public Person Manager
{
    get { return _manager; }
    set { UpdateValue(ref _manager, value); }
}

and then add this column to the grid:

<telerik:DataGridTextColumn PropertyName="Manager.Name" 
                            HeaderText="Manager"/>
When you run the application and get to that grid, you'll see one of 2 things. Either the grid throws a null reference exception or it looks something like this:
4 comments
Teddy
Posted on: 28 Nov 2022 14:59

Thanks Didi for taking another look.

ADMIN
Didi
Posted on: 24 Nov 2022 10:36

Hello Teddy,

My name is Dobrinka and I am part of the support engineering team here at Progress. I have reviewed the case and the provided details and here are my notes:

Please accept my apologies for misunderstanding the situation. After further discussion with the team, we agreed that the scenario you want to achieve is valid, so I have logged a feature request on your behalf for null values support for nested properties. Here is the logged item: https://feedback.telerik.com/maui/1588344-datagrid-provide-support-for-nested-properties-with-null-values Cast your vote and follow the item to track its progress.

I understand that somehow in this scenario exception is unexpected. Fixing the exception won't solve the general beahvior, as there is a missing feature in the control. For example, the column will be empty but major DataGrid features won't work (features like: editing, filtering, sorting, etc.). - This is the reason why the bug is declined and a feature request is opened on your behalf. I hope I was able to explained the situation. 

In addition, I understand that you have a WPF DataGrid which covers the scenario you have and want the .NET MAUI Grid to cover all features you use in WPF. But WPF and .NET MAUI are two different frameworks and technologies. The controls have different implementation and different set of features. I can assure you that we constantly improve our controls and customer feedback is important. Let me know if you have any additional questions and or comments. 

Regards,

Didi
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Teddy
Posted on: 22 Nov 2022 15:35

That doesn't make any sense. I just told you your code has a VERY easy to reproduce NullReferenceException, which wouldn't happen with the WPF RadGridView, and your rationale for not fixing it is "the NullReferenceException is to be expected"...

I have data I want to show from 2 different backends. When I get the response from the first backend service, I want to display the data ASAP, even if the 2 or 3 columns from the 2nd backend are empty. You're saying I either have to a) wait to display the data when all data is ready or b) Set the objects from the 2nd backend service = new() dummy object until it comes in? You're comfortable with that? Why add yet another discrepancy with how your controls work across different platforms? This all works fine in WPF... and in XAML in general. XAML handles null property paths without exceptions, as a standard.

ADMIN
Nikola
Posted on: 22 Nov 2022 13:58

Hello Teddy,

Thank you for sharing your case with us.

I have researched the case in detail and here are my notes:

The exception is expected as there are no Manager elements in the collection. In order to avoid the NullReferenceException the Manager should not be null. All properties inside the Person business model could be null.

There is no problem to use PropertyName = "Manager.Name" and here the value of the Name could be null. More information about the Nested Properties can be found here: https://docs.telerik.com/devtools/maui/controls/datagrid/columns/nested-properties.

I have changed the status of this bug report to Declined as it is not relevant for the DataGrid control.

Regards, Nikola Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.