Capturing SfGrid edit events

If I don't define GridColumns, how do I capture edit events?

1 Reply 1 reply marked as answer

RN Rahul Narayanasamy Syncfusion Team May 3, 2021 01:38 PM UTC

Hi Bytemon, 

Greetings from Syncfusion. 

Query: Capturing SfGrid edit events - If I don't define GridColumns, how do I capture edit events? 

We have validated your query and you want to capture the edit events when you don’t explicitly define the GridColumns. You can capture the Grid events(OnActionBegin and OnActionComplete) events even if you don’t define Grid columns. In the below example, we don’t define GridColumns in the Grid. Find the below code snippets and sample for your reference. 

@using System.ComponentModel.DataAnnotations; 
 
<SfGrid DataSource="@Orders" AllowPaging="true" Toolbar="@(new List<string>() { "Add", "Edit", "Delete", "Cancel", "Update" })" Height="315"> 
    <GridEditSettings AllowAdding="true" AllowEditing="true" AllowDeleting="true" Mode="EditMode.Normal"></GridEditSettings> 
    <GridEvents OnActionBegin="ActionBeginHandler" OnActionComplete="ActionCompletedHandler" TValue="Order"></GridEvents> 
</SfGrid> 
 
@code{ 
    public List<Order> Orders { get; set; } 
 
     . .  
    public void ActionBeginHandler(ActionEventArgs<Order> args) 
    { 
        // Here you can customize your code 
    } 
    public void ActionCompletedHandler(ActionEventArgs<Order> args) 
    { 
        // Here you can customize your code 
    } 
    public class Order 
    { 
        [Key] 
        public int? OrderID { get; set; } 
        public string CustomerID { get; set; } 
        public DateTime? OrderDate { get; set; } 
        public double? Freight { get; set; } 
        public string ShipCountry { get; set; } 
    } 
} 



Reference

Please let us know if you have any concerns. 

Regards, 
Rahul 


Marked as answer
Loader.
Up arrow icon