Error occurs when adding in treegrid

An error occurs when adding


hello.


I am working with TreeGrid.


However, when you click "Add", the following error message appears.


"blazor.server.js:1

  [2024-05-23T05:21:08.100Z] Error: System.NullReferenceException: Object reference not set to an instance of an object.

    at Syncfusion.Blazor.TreeGrid.Internal.Edit`1.ActionBegin(ActionEventArgs`1 args, ActionEventArgs`1 remoteArgs)

    at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__128_0(Object state)

    at Microsoft.AspNetCore.Components.Rendering.RendererSynchronizationContext.PostAsync[TState](Task antecedent, Action`1 callback, TState state)"


so,


https://blazor.syncfusion.com/demos/tree-grid/inline-editing?theme=fluent


After importing the source code here and modifying the “TreeGridEditSettings” part,


"<TreeGridEditSettings AllowAdding="true" AllowEditing="true" AllowDeleting="true" Mode="Syncfusion.Blazor.TreeGrid.EditMode.Row" NewRowPosition="RowPosition.Below"></TreeGridEditSettings>"


Even if you test it, the same error occurs when you click "Add".


I checked and found that an error occurs when I press "Add" when a row in the grid is selected, but if there is no selected row, it works normally.


It seems that there must be a selected row in order to insert the parentid into the new row to be created, but I would like to know why an error occurs.


(syncfusion ver - 24.2.3)

스크린샷 2024-05-23 143205.png

스크린샷 2024-05-23 143238.png


3 Replies

FS Farveen Sulthana Thameeztheen Basha Syncfusion Team May 25, 2024 10:50 AM UTC

Hi Junghwi,


Greetings from Syncfusion.


We have prepared sample from shared demo link but we are able to replicate the problem while adding after selection. Refer to the sample attached


We need some more additional detail to find the cause of the issue. Share us the following details.


  1. Complete TreeGrid code(Any modifications other than this).
  2. Have you faced the issue on enabling specific properties(like Virtualization or any other).
  3. If possible replicate from above shared sample and revert us back.


Regards,

Farveen sulthana T


Attachment: BlazorApp1local_ff5f9196.zip


JU junghwi replied to Farveen Sulthana Thameeztheen Basha May 26, 2024 03:09 PM UTC

There are a few things I don't understand while testing the source code you sent me.


1. "this.TreeData = DateOnlyTimeOnlyData.GetWrapData().ToList();"

When running, it executes normally within "protected override void OnInitialized()", but no data is displayed in TreeGrid in "protected override async Task OnAfterRenderAsync(bool firstRender)".

Image_2064_1716736080814


2. There is a source that I am working on. There, data appears only when EnableVirtualization="true" is set in the TreeGrid property.

(Data is received remotely from DB.)


3. By any chance, should the top parent value be null?


Please reply.



SM Shek Mohammed Asiq Abdul Jabbar Syncfusion Team June 3, 2024 08:29 PM UTC

Junghwi,


We need additional information to proceed further. Please share the following information to proceed further.


For Query 1 :

  1. Are you using both OnInitialize and OnAfterRenderAsync to define the dataSource?
  2. Can you define the reason for assigning dataSource in OnAfterRenderAsync?

For query 2 :

  1. As you mentioned, you are using remode data, how you have bound the dataSource i.e., are you binding Json data returned from the backend or you are using Datamanager?
  2. Adaptor that you are using in your sample.

For Query 3 :

The top parent id should always be null. Kindly share more details regarding this requirement.

Kindly share the above details to proceed further.


Regards,

Shek


Loader.
Up arrow icon