Posted 25 December 2024, 11:00 pm EST
Hello.
I want an event to occur immediately when a value is entered into a cell in the flexgrid.
Forums Home / ComponentOne / Blazor Edition
Posted by: soraroid on 25 December 2024, 11:00 pm EST
Posted 25 December 2024, 11:00 pm EST
Hello.
I want an event to occur immediately when a value is entered into a cell in the flexgrid.
Posted 26 December 2024, 3:16 am EST
Hi,
As per my understanding, you want an event when the user changes a value in the cell. You could use the following code snippet:
private void OnPrepareCellForEdit(object sender, GridCellEditEventArgs args)
{
if (args.Editor is C1TextBox editor)
{
editor.TextChanged = EventCallback.Factory.Create<string>(this, (text) =>
{
OnTextChanged(text, args); // Pass the text and args
});
}
}
private void OnTextChanged(string text, GridCellEditEventArgs args)
{
Console.WriteLine($"Text changed: {text}");
}
The idea is to get the underlying editor in the OnPrepareCellForEdit event and then bind the change event to the editor. You could also refer to the attached sample that demonstrates the same. Similarly, for other editors, you could bind the respective events.
References:
PrepareCellForEdit Property: https://developer.mescius.com/componentone/docs/blazor/online-blazor/C1.Blazor.Grid~C1.Blazor.Grid.FlexGrid~PrepareCellForEdit.html
C1TextBox Class: https://developer.mescius.com/componentone/docs/blazor/online-blazor/C1.Blazor.Input~C1.Blazor.Input.C1TextBox.html
TextChanged Property: https://developer.mescius.com/componentone/docs/blazor/online-blazor/C1.Blazor.Input~C1.Blazor.Input.C1TextBox~TextChanged.html
Regards,
Ankit