We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

AutoFill event handler

Dear Support !

We have defined the Grid CellSaved eventhandler method. It also works fine if the cell is modified. But if we change several cells with Autofill (EnableAutoFill=true) -> the event manager does not run on them. How can we catch/manage the modification if several cells are modified with the Autofill procedure?

Thank you in advance for your help!


3 Replies

BL Balamurugan Lakshmanan Syncfusion Team February 14, 2023 01:24 PM UTC

Hi Szoke,


Thank you for reaching out to Syncfusion support.


We understand that you are looking for a way to handle changes made through Autofill in the Grid. To accomplish this, we recommend use the BeforeAutoFillCell and BeforeAutoFill event. We plan to provided the above events support for AutoFill Action in 20.4.38 Main Release.


We have attached a code snippet and a sample solution file for your reference. Please check it out.


<SfGrid DataSource="@Orders" EnableAutoFill="true" AllowSelection="true" Toolbar="@(new List<string>() { "Add", "Update","Cancel" })" AllowPaging="true">

    <GridEvents BeforeAutoFill="BeforeAutoFill" BeforeAutoFillCell="BeforeAutoFillCell" TValue="Order"></GridEvents>

 

    <GridSelectionSettings CellSelectionMode="CellSelectionMode.Box" Mode="SelectionMode.Cell" Type="SelectionType.Multiple"></GridSelectionSettings>

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

    <GridColumns>

        <GridColumn Field=@nameof(Order.OrderID) HeaderText="Order ID" IsPrimaryKey="true" TextAlign="TextAlign.Right" Width="120" ValidationRules="@(new ValidationRules{ Required= true })"></GridColumn>

        <GridColumn Field=@nameof(Order.CustomerID) HeaderText="Customer Name" Width="150"></GridColumn>

        <GridColumn Field=@nameof(Order.OrderDate) HeaderText=" Order Date" Format="d" Type="ColumnType.Date" TextAlign="TextAlign.Right" Width="130"></GridColumn>

        <GridColumn Field=@nameof(Order.Freight) HeaderText="Freight" Format="C2" TextAlign="TextAlign.Right" Width="120"></GridColumn>

    </GridColumns>

</SfGrid>

 

@code {

    public List<Order> Orders { get; set; }

 

    protected override void OnInitialized()

    {

        Orders = Enumerable.Range(1, 75).Select(x => new Order()

            {

                OrderID = 1000 + x,

                CustomerID = (new string[] { "ALFKI", "ANANTR", "ANTON", "BLONP", "BOLID" })[new Random().Next(5)],

                Freight = 2.1 * x,

                OrderDate = DateTime.Now.AddDays(-x),

            }).ToList();

    }

 

    public class Order

    {

        public int? OrderID { get; set; }

        public string CustomerID { get; set; }

        public DateTime? OrderDate { get; set; }

        public double? Freight { get; set; }

    }

   

    public void BeforeAutoFill(BeforeAutoFillEventArgs args)

    {

        // Here, you can customize your code.

    }

    public void BeforeAutoFillCell(BeforeAutoFillCellEventArgs<Order> args)

    {

        // Here, you can customize your code.

    }

 

}


We hope that this solution addresses your concern. If you have any further queries, please do not hesitate to reach out to us.


Best regards,

Bala.


Attachment: BlazorApp1_dab2f771.zip


SZ Szoke February 22, 2023 03:52 PM UTC

Thanks, we couldn't find it in the documentation!



VN Vignesh Natarajan Syncfusion Team February 23, 2023 05:08 AM UTC

Hi Szoke,


Thanks for the update.


We already have logged improvement tasks including the documentation on newly introduced events. Currently, we are working on it and it will be refreshed online as soon as possible.


Please get back to us if you have further queries.


Regards,

Vignesh Natarajan


Loader.
Up arrow icon