Add - Update Button Does Not Work

Hello! I have an <sfgrid> setup and when I use the "Add" button and then "Update" nothing happens. The "Update" button stays black after pressed, but doesn't do anything. No processing is attempted and nothing is logged. 

My grid code is below. I have found that if I disable the SfDropdownList on @CarrierList the Add/Update works fine. Once I add this back, it no longer works. 


Can someone help me figure out what I'm doing wrong?


@page "/equipmentpagenew"


@using SimpleYMS.Shared

@using Syncfusion.Blazor.Grids

@using Syncfusion.Blazor.DropDowns




<SfGrid @ref="equipmentGrid" DataSource="@EquipmentList"

        Toolbar ="@(new List<string>() {"Add", "Edit", "Update","Delete","Cancel"})">

    <GridEvents OnActionBegin="ActionBeginHandler" TValue="Equipment"></GridEvents>

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



    <GridColumns>

        <GridColumn IsPrimaryKey = "true" AllowEditing="false" AllowAdding="false"

            Field=@nameof(Equipment.EquipmentId) HeaderText="Equipment ID">

        </GridColumn>

        <GridColumn Field=@nameof(Equipment.EquipmentNumber) HeaderText="Equipment Number"></GridColumn>

        <GridColumn Field=@nameof(Equipment.OwnerSCAC) HeaderText="Owner SCAC"></GridColumn>

        <GridColumn Field=@nameof(Equipment.CarrierId) HeaderText="Carrier ID"></GridColumn>

        <GridColumn Field="Carrier.CarrierName" HeaderText="Carrier Name" Width="140px">

            <EditTemplate>

                <SfDropDownList DataSource="@CarrierList" TItem="Carrier" TValue="int"

                                @bind-Value="@((context as Equipment).CarrierId)">

                    <DropDownListFieldSettings Text="CarrierName" Value="CarrierId"></DropDownListFieldSettings>

                </SfDropDownList>

            </EditTemplate>

        </GridColumn>

        <GridColumn Field=@nameof(Equipment.EquipmentTypeId) HeaderText="Equipment Type ID"></GridColumn>

        <GridColumn Field=@nameof(Equipment.LocationId) HeaderText="Location ID"></GridColumn>

        <GridColumn Field=@nameof(Equipment.EquipmentState) HeaderText="Equipment State">

            <EditTemplate>

                <SfDropDownList DataSource="@EquipmentStateEnumValues" TItem="string" TValue="EquipmentState"

                                @bind-Value="@((context as Equipment).EquipmentState)">

                </SfDropDownList>

            </EditTemplate>

        </GridColumn>

         <GridColumn Field=@nameof(Equipment.EquipmentStatus) HeaderText="Equipment Status">

            <EditTemplate>

                <SfDropDownList DataSource="@EquipmentStatusEnumValues" TItem="string" TValue="EquipmentStatus"

                                @bind-Value="@((context as Equipment).EquipmentStatus)">

                </SfDropDownList>

            </EditTemplate>

        </GridColumn>

        <GridColumn Field=@nameof(Equipment.YardTagNumber) HeaderText="YardTag Number"></GridColumn>

        <GridColumn Field=@nameof(Equipment.EnteredYard) HeaderText="Entered Yard"></GridColumn>

        <GridColumn Field=@nameof(Equipment.YardId) HeaderText="Yard ID"></GridColumn>

        <GridColumn Field=@nameof(Equipment.ClassId) HeaderText="Class ID"></GridColumn>

    </GridColumns>

</SfGrid>



@code

{


    public List<Equipment> EquipmentList { get; set; }


    public List<Carrier> CarrierList { get; set; }


    public SfGrid<Equipment> equipmentGrid { get; set; }


    public string[] EquipmentStatusEnumValues { get; set; } = Enum.GetNames(typeof(EquipmentStatus));


    public string[] EquipmentStateEnumValues { get; set; } = Enum.GetNames(typeof(EquipmentState));


    [Inject]

    public IEquipmentService EquipmentService { get; set; }



    [Inject]

    public ICarrierService CarrierService { get; set; }


    protected override async Task OnInitializedAsync()

    {

        EquipmentList = (await EquipmentService.GetEquipmentAll()).ToList();

        CarrierList = (await CarrierService.GetCarriers()).ToList();

    }



    public async void ActionBeginHandler(ActionEventArgs<Equipment> Args)

    {

        if (Args.RequestType.Equals(Syncfusion.Blazor.Grids.Action.Save))

        {

            if(Args.Action == "Add")

            {


                await EquipmentService.AddEquipment(Args.Data);

                EquipmentList = (await EquipmentService.GetEquipmentAll()).ToList();

                equipmentGrid.Refresh();

            }

            else

            {

                await EquipmentService.UpdateEquipment(Args.Data);


            }

        }

        if (Args.RequestType.Equals(Syncfusion.Blazor.Grids.Action.Delete))

        {

            await EquipmentService.DeleteEquipment(Args.Data.EquipmentId);

        }

    }


}




5 Replies

SE Sean January 19, 2022 05:45 PM UTC

I was able to figure out the problem! Hope no one else ever has to waste as much time as I did figuring it out. 


For some reason the problem was cased by the "Required" DataAnnotation reference. After removing this from my "Carrier" class the Add button worked as expected. 





MS Monisha Saravanan Syncfusion Team January 20, 2022 02:41 PM UTC

Hi Sean, 

Thanks for the update. 

We are glad to hear that you have resolved your query on your own.   

Kindly revert us if we misunderstood or if you have further queries. 

Regards, 
Monisha S 



MA Marc September 19, 2023 12:46 AM UTC

Sean.  I have wasted a bit of time on this, but found this before it became excessive.  Thx.



PF Patrick Fogarty April 28, 2024 11:51 PM UTC

I just ran into this myself. Took me over 1/2 day before I found this thread. Why is it that after more than two years this is not fixed?



PS Prathap Senthil Syncfusion Team April 29, 2024 11:37 AM UTC

Hi Patrick,

Before proceeding with the reporting problem, we require some additional clarification from your end. Please share the following details to proceed further at our end:

  • Are you experiencing any issues when using the Edit template as a dropdown?
  • Could you please share with us when you encountered the error?
  • Could you please share us the grid code snippet with model class?
  • To analyze the reported issue, could you please share a simple and reproducible sample that demonstrates the problem? This will assist us in identifying the issue more efficiently and providing a resolution.
  • Please provide us with a video demonstration of the issue, along with the replication steps.


The above-requested details will be very helpful for us to validate the reported query at our end and provide a solution as early as possible.


Regards,
Prathap S


Loader.
Up arrow icon