GridForeignColumn complex binding throws exception.

 Exception is thrown when GridForeignColumn is added to razor page. Please advice. Thank you.
System.NullReferenceException
  HResult=0x80004003
  Message=Object reference not set to an instance of an object.
  Source=Syncfusion.Blazor
  StackTrace:
   at Syncfusion.Blazor.Grids.Internal.ForeignKey`1.<>c__DisplayClass6_0.<GenerateQuery>b__1(Object res)


Razor Page

<SfGrid TValue="Customer" >
    <SfDataManager 
                   Url="@Url"
                   InsertUrl="@($"{Url}/Insert")"
                   UpdateUrl="@($"{Url}/Update")"
                   RemoveUrl="@($"{Url}/Remove")"
                   Adaptor="Adaptors.UrlAdaptor"></SfDataManager>
    
    <GridEditSettings Mode="EditMode.Dialog"
                      AllowAdding="true"
                      AllowDeleting="true"
                      AllowEditing="true"
                      AllowEditOnDblClick="false"
                      ShowDeleteConfirmDialog="true" />
    <GridColumns>
        <GridColumn Field="Id" HeaderText="Id" IsPrimaryKey="true" IsIdentity="true" Visible="false" ShowInColumnChooser="false" />
        <GridColumn Field="RowVersion" Visible="false" ShowInColumnChooser="false" />

        <GridForeignColumn Field="Email.EmailTypeId" 
                           ForeignKeyField="Id" ForeignKeyValue="Text" TValue="EmailType">
            <Syncfusion.Blazor.Data.SfDataManager  Url="/api/EmailType" Adaptor="Adaptors.UrlAdaptor"></Syncfusion.Blazor.Data.SfDataManager>
        </GridForeignColumn>
        <GridColumn Field="Email.Text" Type="ColumnType.String" />
    </GridColumns>
</SfGrid>

Email.cs
    [Owned]
    public class Email 
    {
        [Display(Name = "EmailType", ResourceType = typeof(Resources.DataAnnotation.Shared.Email))]
        [Required(ErrorMessageResourceName = "RequiredError", ErrorMessageResourceType = typeof(Resources.DataAnnotation.Shared.Email))]
        public int? EmailTypeId { get; set; }
        public virtual EmailType EmailType { get; set; }

        [Display(Name = "Text", ResourceType = typeof(Resources.DataAnnotation.Shared.Email))]
        [Required(ErrorMessageResourceName = "RequiredError", ErrorMessageResourceType = typeof(Resources.DataAnnotation.Shared.Email))]
        [EmailAddress(ErrorMessageResourceName = "EmailError", ErrorMessageResourceType = typeof(Resources.DataAnnotation.Shared.Email))]
        public string Text { get; set; }
    }

Customer.cs
    public class Customer : AbstractEntity
    {
        /// <summary>
        /// Email
        /// </summary>
        [Display(Name = "Email", ResourceType = typeof(Resources.DataAnnotation.Customer))]
        [Required(ErrorMessageResourceName = "RequiredError", ErrorMessageResourceType = typeof(Resources.DataAnnotation.Customer))]
        public Email Email { get; set; }
    }

3 Replies 1 reply marked as answer

VN Vignesh Natarajan Syncfusion Team March 24, 2021 07:30 AM UTC

Hi P,  
 
Thanks for contacting Syncfusion support.  
 
Query: “GridForeignColumn complex binding throws exception.” 
 
We have validated the reported query by preparing a sample using your code example and our latest version Syncfusion.Blazor (18.4.0.49) Nuget package. Kindly refer the below sample for your reference 
 
 
After referring the sample, if you are still facing the reported issue. Kindly share the following details.  
 
  1. Share more details about the issue you are facing.
  2. Are you facing the reported issue during the initial rendering itself or during a certain action?
  3. Share the details about your URL adaptor for both Grid and Column datasource.
  4. If possible share the issue reproducible sample or try to reproduce the reported issue in provided sample.
 
Above requested details will be very helpful for us to validate the reported query at our end and provide better solution as early as possible.  
 
Regards, 
Vignesh Natarajan 



P p March 25, 2021 08:09 AM UTC

Hi Vignesh,

Thanks for your reply. I have updated to Syncfusion.Blazor (18.4.0.49) and am still facing some issues. Please find attached zip file. I have managed to reproduce the error. The error happens during the initial rendering of grid data. 

Index.razor

<SfGrid TValue="EmployeeData"
        AllowSorting="true"
        AllowResizing="true"
        AllowReordering="true"
        AllowPaging="true"
        AllowFiltering="true"
        AllowSelection="true"
        EnablePersistence="false"
        Query="@Query"
        Toolbar="@Toolbar">

    <GridEvents OnActionBegin="ActionBeginHandler"
                OnActionFailure="ActionFailureHandler"
                OnActionComplete="ActioCompleteHandler"
                TValue="EmployeeData"></GridEvents>
    <SfDataManager Url="/api/Values" Adaptor="Adaptors.UrlAdaptor"></SfDataManager>

    <GridPageSettings PageSize="10" />
    <GridFilterSettings Type="Syncfusion.Blazor.Grids.FilterType.Excel" />
    <GridEditSettings Mode="EditMode.Dialog"
                      AllowAdding="true"
                      AllowDeleting="true"
                      AllowEditing="true"
                      AllowEditOnDblClick="false"
                      ShowDeleteConfirmDialog="true" />
    <GridColumns>
        <GridColumn Field="Id" HeaderText="Id" IsPrimaryKey="true" IsIdentity="true" Visible="false" ShowInColumnChooser="false" />
        
            <GridForeignColumn Field="Name.FirstName"
                               ForeignKeyField="Id" ForeignKeyValue="Nam" TValue="Emp">
                <Syncfusion.Blazor.Data.SfDataManager Url="/api/Foreign" Adaptor="Adaptors.UrlAdaptor"></Syncfusion.Blazor.Data.SfDataManager>
            </GridForeignColumn>
        
        <GridColumn Field="Name.Text" Type="ColumnType.String" />
    </GridColumns>
</SfGrid>

@code {
    
    
    public object Toolbar { get; set; } = new List<object>() { "Add", "Edit", "Delete", "Cancel", "Update" };

    public Query Query { get; set; } = new Query();


    /// <param name="args"></param>
    public void ActionBeginHandler(ActionEventArgs<EmployeeData> args)
        {

        }

        public void ActioCompleteHandler(ActionEventArgs<EmployeeData>
            args)
            {
            }


            /// <param name="args"></param>
            public void ActionFailureHandler(Syncfusion.Blazor.Grids.FailureEventArgs args)
            {
            var err = args.Error.InnerException?.ToString();

            }
    }

Regards,
P

Attachment: 20210325UrlAdaptor_416e99a8.zip


VN Vignesh Natarajan Syncfusion Team March 29, 2021 11:00 AM UTC

Hi P, 
 
Thanks for sharing the issue reproducible sample    
 
Query: “Exception is thrown when GridForeignColumn is added to razor page. Please advice.  
 
We have confirmed the reported query as a bug and logged the defect report “Exception throws while defining foreignkey column field as complex field with pagingfor the same. Thank you for taking the time to report this issue and helping us improve our product. At Syncfusion, we are committed to fixing all validated defects (subject to technological feasibility and Product Development Life Cycle ) and including the defect fix in our weekly release which is expected to be rolled out by mid of May 2021. We will update you once the release is rolled out.    
       
You can now track the current status of your request, review the proposed resolution timeline, and contact us for any further inquiries through this link.       
   
 
Till then we appreciate your patience.   
 
Regards, 
Vignesh Natarajan  
 
 
 
 
 


Marked as answer
Loader.
Up arrow icon