How to trigger event or method when row value sets in Data grid?

Scenario : DataGrid :
Example:

Column 1    |     Column 2 

Empty Row      Empty Row   0
Empty Row      Empty Row   1


When i edit the Empty Row [0] with  value (123) .I need to trigger a method. How can i have achieve this?



1 Reply 1 reply marked as answer

KK Karthikraja Kalaimani Syncfusion Team March 5, 2021 12:52 PM UTC

Hi Bharath,

You can detect the done and enter button press key while editing on Completed Event of the CustomRenderer for GridTextColumn and GridNumericColumn. For more details please refer to the below code snippet and attached sample.

Code snippet :

 
public partial class MainPage : ContentPage 
    { 
        public MainPage() 
        { 
            InitializeComponent(); 
            this.myGrid.CellRenderers.Remove("Numeric"); 
            this.myGrid.CellRenderers.Add("Numeric", new CustomNumericRenderer()); 
            this.myGrid.CellRenderers.Remove("TextView"); 
            this.myGrid.CellRenderers.Add("TextView", new CustomTextViewRenderer()); 
 
        } 
        protected override void OnDisappearing() 
        { 
            this.myGrid.Dispose(); 
            base.OnDisappearing(); 
        } 
    } 
 
    public class CustomNumericRenderer : GridCellNumericRenderer 
    { 
         
        public CustomNumericRenderer() 
        { 
             
        } 
 
        protected override SfNumericTextBoxExt OnCreateEditUIView() 
        { 
            var view = new NumericTextBox(); 
            return view; 
        } 
    } 
 
    public class NumericTextBox : SfNumericTextBoxExt 
    { 
        SfDataGrid dataGrid; 
        /// <summary> 
        /// Initializes a new instance of the <see cref="NumericTextBoxView"/> class. 
        /// </summary>  
        public NumericTextBox() 
        { 
            this.Completed += NumericTextBox_Completed; 
        } 
 
        private void NumericTextBox_Completed(object sender, EventArgs e) 
        { 
             
        } 
    } 
 
 
    public class CustomTextViewRenderer : GridCellTextViewRenderer 
    { 
 
        public CustomTextViewRenderer() 
        { 
         
        } 
 
        protected override SfEntry OnCreateEditUIView() 
        { 
            var view = new CustomEntry(); 
            return view; 
        } 
    } 
 
 
 
    public class CustomEntry : SfEntry 
    { 
 
        public CustomEntry() 
        { 
 
            this.Completed += CustomEntry_Completed; 
        } 
 
        private void CustomEntry_Completed(object sender, EventArgs e) 
        { 
            
        } 
    } 

sample link : https://www.syncfusion.com/downloads/support/directtrac/general/ze/DataGridDemo2105544065-192499787.zip

We hope this helps, please let us know if you need further assistance from us.

Regards,
Karthik Raja 


Marked as answer
Loader.
Up arrow icon