OnActionComplete loop

Hello,

I'm trying to catch the OnActionComplete event when a button from the toolbar is used.

my code :


When i click on the add button, the Grid component don't display the inline editing and it seems to be locked in an infinite loop

The event fired in a infinite loop ....

The output form in Visual Studio



[edit]

To complet my answer, the first call is RequestType.Add

but all others are Refresh type.


Could you help me please ?


Thanks by advance,

Regards



7 Replies

MS Monisha Saravanan Syncfusion Team May 22, 2023 01:23 PM UTC

Hi Alexandre,


Greetings from Syncfusion support.


We have checked your reported issue at our end. But we could not able to replicate the reported issue. Kindly check the attached sample for your reference. If you still face difficulties then kindly share the below details to validate the issue further from our side.


  • Share us the entire Grid code snippet.
  • Share us the Nuget version used at your end.
  • Share us the video demonstration of the issue.
  • If possible share us simple issue reproducing sample or try to reproduce the reported issue on the below attached sample. So that we will validate and we will check the reported issue in the provided sample.


The above provided details will be very helpful for us to validate the reported query at our end and provide the solution as early as possible also Kindy get back to us if you need further assistance


Also we would like to inform the in DataGrid we have event for toolbar click. Kindly use this event to catch the toolbar click event.


Reference: https://blazor.syncfusion.com/documentation/datagrid/events#ontoolbarclick


Regards,

Monisha



AC Alexandre CLAVERIE May 22, 2023 01:51 PM UTC

Hello,


I shared you the complete VIsual Studio Solution.

I use the following nugets packages :

  • Syncfusion.Blazor.Core 2.1.2.5
  • Syncfusion.Blazor.Grid 2.1.2.5
  • Syncfusion.Blazor.Themes 2.1.2.5

The video and source are in the rar file attached.

The event for the toolbar click, make me the same issue  :
The toobar don't appears, and the event loop.

Thanks for your help

Attachment: AmbroisieWeb_1ecb8bd.rar


IR Indumathi Ravichandran Syncfusion Team May 23, 2023 07:29 AM UTC


Hi Alexandre,


We have checked your shared sample and we are facing the below exception because database is not linked to the current project. So we have modified the project by giving it an list data. But we could not able to reproduce the issue. It is working fine. Kindly refer the modified project at your end. If you still face difficulties then kindly share us the database used at your end to replicate the issue.


public class UnitsViewModel : BaseViewModel

    {

        //private AmbroisieContext _context = new AmbroisieContext();

        private List<Unit> _context = new List<Unit>();

 

     

        public UnitsViewModel()

        {

        }

        public List<Unit> Units

        {

            get

            {

                return _context;

            }

        }

 

        public void Add()

        {

            _context.Add(new Unit());

            PropertyChange(nameof(Units));

        }


Please let us know if you have any concerns.


Regards,

Monisha


Attachment: AmbroisieWeb_e16daff3.zip


AC Alexandre CLAVERIE May 23, 2023 03:54 PM UTC

Hello,


I make the same changes as you, but the issue persist.


I shared you the SQL Script to create the identical Database. It's on an SQL Server 12.0.4100.1.

nugets packages uses for the database :

  • Microsoft.EntityFramworkCore 8.0.0-preview.4.232259.3
    Microsoft.EntityFramworkCore.SqlServer 8.0.0-preview.4.232259.3
    Microsoft.EntityFramworkCore.Tools 8.0.0-preview.4.232259.3

Another nugets packages it's used on the solution :

  • bootstrap 5.3.0-alpha3



Attachment: AmbroisieDB_681e0079.rar


MS Monisha Saravanan Syncfusion Team May 24, 2023 12:29 PM UTC


Hi Alexandre,


Thanks for the update.


We could able to reproduce the issue on connecting the database. We could see that you have connected the list value directly to the datasource. So it keep on refreshing for every operation. So we suggest you to use an local variable to bind the datasource to the Grid instead of binding the list directly. Kindly check the below attached code snippet and sample for your reference.


@using AmbroisieWeb.Models

 

@page "/unitsview"

@inject UnitsViewModel ViewModel

 

<h3>UnitsView</h3>

 

@if (ViewModel.Units != null)

{

    <SfGrid @ref=Grid DataSource="@Units" Toolbar="@ToolbarItems">

        <GridEvents  OnActionComplete="OnActionCompleteHandler" OnActionBegin="ActionBegin" TValue="Unit"></GridEvents>

        <GridEditSettings AllowAdding="true" AllowDeleting="true" AllowEditing="true"></GridEditSettings>

        <GridColumns>

            <GridColumn Field="@nameof(Unit.UnitName)" HeaderText="Nom" Width="120"></GridColumn>

            <GridColumn Field="@nameof(Unit.UnitSymbol)" HeaderText="Symbole" Width="25"></GridColumn>

        </GridColumns>

    </SfGrid>

}

else

{

    <label>Aucunes données</label>

}

 

 

@code {

    SfGrid<Unit> Grid;

    public List<Unit> Units { get; set; }

 

 

    private List<string> ToolbarItems = new List<string>() { "Add", "Edit", "Delete", "Update", "Cancel" };

 

    protected override void OnInitialized()

    {

        Units = ViewModel.Units;

        System.Diagnostics.Debug.WriteLine("*** UnitsView OnInitialized ***");

    }

 

   

 

    public void ActionBegin(ActionEventArgs<Unit> args)

    {

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

        {

         //   args.Cancel = true;

        }

        System.Diagnostics.Debug.WriteLine("OnActionBeginHandler Raised");

        System.Diagnostics.Debug.WriteLine("OnActionBeginHandler RequestType:" + args.RequestType);

 

    }

    public void OnActionCompleteHandler(ActionEventArgs<Unit> args)

    {

 

       System.Diagnostics.Debug.WriteLine("OnActionCompleteHandler Raised");

        System.Diagnostics.Debug.WriteLine("OnActionCompleteHandler RequestType:" + args.RequestType);

    }

 

 

}

 


Please let us know if you have any concerns.


Regards,

Monisha


Attachment: AmbroisieWeb_5cc3ccb.zip


AC Alexandre CLAVERIE May 24, 2023 07:29 PM UTC

Yes, it's works, thanks to you.




MS Monisha Saravanan Syncfusion Team May 25, 2023 04:31 AM UTC

Hi Alexandre,


Welcome. We are glad to hear that the reported issue has been resolved at your end. If you have further queries then kindly get back to us as always we will be happy to assist you.


Regards,

Monisha


Loader.
Up arrow icon