Json object containing null childs.

Hi, I hope can can explain my this correctly.
When theplanonUserObject is null i getSystem.NullReferenceException: Object reference not set to an instance of an object.
How can i get arround this?

I have a JSON object like this:
{
"samaccountname": "xxx",
"userprincipalname": "xxx",
"planonUserObject": null
},
{
"samaccountname": "yy",
"userprincipalname": "yy",
"planonUserObject": {
"eMail": "yyy",
"personCode": "yyy"
}
}
My grid looks like this:
Width="150">
HeaderText="Group" TextAlign="TextAlign.Left" Width="150">

3 Replies

RS Renjith Singh Rajendran Syncfusion Team December 8, 2020 09:09 AM UTC

Hi Rauden, 

Greetings from Syncfusion support. 

We are not clear about the exact scenario you are facing the reported problem. We tried a sample with the shared details but, we could not face any exception. We are attaching the sample for your reference, please download the sample form the link below, 
 
 
If we have misunderstood your query, or if you still need further assistance, then the following details would be helpful for us to proceed further. 
  1. Share the sample which you have tried from your side. This would be helpful for us to validate the problem based on your scenario.
  2. Or if possible, reproduce the problem with the attached sample and share with us for further analysis.
  3. Share the exact scenario or proper replication procedure.
  4. Share the complete Grid rendering codes and Grid model class codes.
  5. Share the video demo showing the problem you are facing.

The provided information will help us analyze the problem, and provide you a solution as early as possible. 

Regards, 
Renjith Singh Rajendran 



RA raduen December 8, 2020 09:18 AM UTC

Hi Renjith Singh Rajendran,
I just saw that is missed the grid code:
<SfGrid @ref="@Grid" DataSource="@GroupDataList" AllowSelection="true" RowHeight="60" Toolbar="@(new List<string>() { "search" })">
            <GridSelectionSettings Type="SelectionType.Single"></GridSelectionSettings>
            <GridColumns >               
                </GridColumn>
                <GridColumn Field=@nameof(ADUserObject.displayname) HeaderText="Name" TextAlign="TextAlign.Left"
                            Width="250" MinWidth="250" MaxWidth="275" IsFrozen="true"></GridColumn>
                <GridColumn Field=@nameof(ADUserObject.initials) HeaderText="Initialen" TextAlign="TextAlign.Left" Width="35"></GridColumn>

                <GridColumn Field=@nameof(planonUserObject.eMail) HeaderText="Voornaam" TextAlign="TextAlign.Left" Width="65"></GridColumn>
                    ......
            
If plannonUserObject is null i get System.NullReferenceException: Object reference not set to an instance of an object.


RS Renjith Singh Rajendran Syncfusion Team December 9, 2020 02:51 PM UTC

Hi Rauden, 

Thanks for your update. 

As provided in the sample and documentation shared from our previous update, we suggest you to set the Field property as like the below code to overcome the reported problem. 

 
<GridColumn Field="planonUserObject.eMail" HeaderText="Date" ... ></GridColumn> 


Please find the documentation for your reference, 

Regards, 
Renjith Singh Rajendran 


Loader.
Up arrow icon