Event when the user changes a cell, but doesn´t leave it

Hello,

I´m using a SfDataGrid with a DataTable as datasource. The user can edit the cell values. Now I´m searching for an event when the user changes a value in a date-column, but didn´t leave the cell. I have the following other cell-types:

- text-cell: I can use the "CurrentCellKeyUp" event to get the value the user typed in the cell
- combobox-cell: I can use the "CellComboBoxSelectionChanged" event to get the value, when the user changes a combobox inside a cell
- checkbox-cell: I can use the "CellCheckBoxClick" event to get the value of a checkbox the user clicks in a cell
- date-cell: I couldn´t find an event to get noticed, when the user changed the date.

"CurrentCellEndEdit" doesn´t work, as it only fires, after the user leaves the cell.

How to do it with a date-column and is there an easier way to get the value of the changed cell, before the user leaves it?

Thank you.
Michael

3 Replies 1 reply marked as answer

DM Dhanasekar Mohanraj Syncfusion Team November 30, 2020 12:23 PM UTC

Hi Michael Witzik,

 
Thank you for using Syncfusion controls.

 
You can get the changed date in GridDateTimeColumn without leaving the cell by overriding OninitializedEditElement in GridDateTimeCellRenderer class like below. 
this.sfDataGrid1.CellRenderers.Remove("DateTime"); 
this.sfDataGrid1.CellRenderers.Add("DateTime", new GridDateTimeCellRenderersExt(sfDataGrid1)); 
public class GridDateTimeCellRenderersExt : GridDateTimeCellRenderer 
{ 
    SfDataGrid DataGrid { get; set; } 
    public GridDateTimeCellRenderersExt(SfDataGrid dataGrid) 
    { 
        this.DataGrid = dataGrid; 
    } 
    protected override void OnInitializeEditElement(DataColumnBase column, RowColumnIndex rowColumnIndex, SfDateTimeEdit uiElement) 
    { 
        base.OnInitializeEditElement(column, rowColumnIndex, uiElement); 
        uiElement.ValueChanged += UiElement_ValueChanged; 
    } 
 
    private void UiElement_ValueChanged(object sender, Syncfusion.WinForms.Input.Events.DateTimeValueChangedEventArgs e) 
    { 
        var changeddate = e.NewValue; 
        // You can get the changed date  
    } 
} 

We have prepared the sample for the same,

 


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

 
Regards,
Dhanasekar Mohanraj. 


Marked as answer

MW Michael Witzik December 2, 2020 10:01 AM UTC

Hello Dhanasekar,

thank you! Your solution worked as described.

Kind regards
Michael


VS Vijayarasan Sivanandham Syncfusion Team December 3, 2020 04:50 AM UTC

Hi Michael Witzik, 
 
Thanks for the update. 
 
We are glad to know that the reported problem has been resolved at your end. Please let us know if you have any further queries on this. We are happy to help you😊. 
 
Regards, 
Vijayarasan S 


Loader.
Up arrow icon