Data Grid throws errors when i add an event syncfusion.blazor.pdb not loaded

I am using the datagrid control, and using data within the page is fine, and also when i first populate the grid it is fine.....

But when i add an event to my datagrid and when it makes a call to an Api it keeps erroring out half way through getting the data.. as below 

fAnd the exception is a null reference, which makes me think that although the method is async its still trying to populate the event even tho i have not clicked a button etc


 

3 Replies 1 reply marked as answer

DI Dingo October 8, 2020 01:28 PM UTC

<SfGrid DataSource="@ReworkReplacement" Toolbar="@(new List<string>() { "Add", "Edit" })" Height="415" Width="100%" AllowPaging="true" AllowSorting="true" AllowFiltering="true" AllowGrouping="true">

                        <GridEvents OnLoad="load" TValue="GridSpecialRelease"></GridEvents>

                        <GridFilterSettings Type="Syncfusion.Blazor.Grids.FilterType.Menu"></GridFilterSettings>

                        <GridEditSettings AllowAdding="true" AllowEditing="true" AllowDeleting="true" Mode="EditMode.Dialog"></GridEditSettings>

                        <GridPageSettings PageSize="20"></GridPageSettings>

                        @*<GridEvents OnActionBegin="Begin" TValue="Order"></GridEvents>*@


                        <GridColumns>

                            <GridColumn Field="Pattern" HeaderText="Pattern" IsPrimaryKey="true" TextAlign="TextAlign.Center" Width="120"></GridColumn>

                            <GridColumn Field="Reason" HeaderText="Reason" Width="150" TextAlign="TextAlign.Center"></GridColumn>

                            <GridColumn Field="ComponentIdentifier" HeaderText=" Component" Type="ColumnType.Date" TextAlign="TextAlign.Center" Width="120"></GridColumn>

                            <GridColumn Field="RecipeName" HeaderText="Recipe" TextAlign="TextAlign.Center" Width="120"></GridColumn>

                            <GridColumn Field="StepNumber" HeaderText="Step" TextAlign="TextAlign.Center" Width="120"></GridColumn>

                            <br />

                            <GridColumn Field="StartDate" HeaderText="Start Date" Format="d" TextAlign="TextAlign.Center" Width="120"></GridColumn>

                            <GridColumn Field="EndDate" HeaderText="End Date" Format="d" TextAlign="TextAlign.Center" Width="120"></GridColumn>

                            <GridColumn Field="AddedBy" HeaderText="Added by" TextAlign="TextAlign.Center" Width="120"></GridColumn>

                            <GridColumn Field="AddedOnUtc" HeaderText="AddedOnUtc" Format="d" TextAlign="TextAlign.Center" Width="120"></GridColumn>

                        </GridColumns>

                    </SfGrid>



    public async void Begin(ActionEventArgs<Order> args)

    {

        if (args.RequestType == Syncfusion.Blazor.Grids.Action.Save)

        {

            await SuccessBtnOnClick();

        }

        if (args.RequestType == Syncfusion.Blazor.Grids.Action.Delete)

        {

            await DeleteBtnOnClick();

        }

    }

protected override async Task OnInitializedAsync()

        {

            await LoadData();

        }


        private async Task LoadData()

        {

            try

            {

                GetReworkPartReplacementRequest request = new GetReworkPartReplacementRequest()

                {

                    ReworkPartReplacements = new List<string>()

                };



                this.ReworkReplacement = (await IReworkPartReplacement.ReworkPartReplacementGetList(request)).ToList();

            }


            catch (Exception ex)

            {

                AuditService.HandleException(MethodBase.GetCurrentMethod()

                    , ex

                    , new object[] { }

                    , new object[] { });

            }

        }

        public void load()

        {

            string test = "hey";

        }


    }


Is throws the error half way through the LoadData task.. Where if i remove the event from the grid.. My data populates





DI Dingo October 8, 2020 01:43 PM UTC

So its actually throwing the null ref error after my postback from my API... But this is only when i am trying to use <gridevents>


RS Renjith Singh Rajendran Syncfusion Team October 9, 2020 08:57 AM UTC

Hi Dom, 

Greetings from Syncfusion support. 

We suggest you to ensure to provide proper/same model class name as value for the TValue property of GridEvents to overcome the problem you are facing. As in OnLoad and OnActionBegin events, have different TValue as GridSpecialRelease and Order, caused the reported problem. 

We suggest you to ensure this case from your side. Please refer the codes below, 

 
<SfGrid DataSource="@ReworkReplacement" Toolbar="@(new List<string>() { "Add""Edit" })" ...> 
   <GridEvents OnLoad="load" TValue="Order"></GridEvents> 
    ... 
    <GridPageSettings PageSize="20"></GridPageSettings> 
    <GridEvents OnActionBegin="Begin" TValue="Order"></GridEvents> 
    ... 
</SfGrid> 



We are also attaching a sample based on the shared codes. Please download the sample from the link below, 
 
Please get back to us if you need further assistance. 

Regards, 
Renjith Singh Rajendran 


Marked as answer
Loader.
Up arrow icon