Hi,
I have a SfDataGrid with GridComboBoxColumn, DropDownStyle.DropDown and AutoCompleteMode.Suggest. If user enters some text that is not in the list currently, I want to be able to save the new text, preferrably in sfDataGrid.CurrentCellValidating.
I'm sorry if I miss the obvious, but how it is possible to access the user entered text? The only way I found is using custom cell renderer and passing data using TableControl.Text property, but this property seems to be empty on CurrentCellValidating event. Is there a better way?
private void sfDataGrid_CurrentCellEndEdit(object sender, CurrentCellEndEditEventArgs e)
{
if (e.DataColumn.GridColumn.MappingName == "MyColumn")
{
var userText = (e.OriginalSender as SfDataGrid)?.TableControl.Text;
}
}
public class MyGridComboBoxCellRenderer : GridComboBoxCellRenderer
{
protected override void OnEditingComplete(DataColumnBase column, SfComboBox currentRendererElement)
{
if (column.GridColumn.MappingName == "MyColumn")
{
var userText = column?.GridColumn?.Renderer?.CurrentCellRendererElement?.Text.Trim();
if (userText?.Length > 0)
TableControl.Text = userText;
}
base.OnEditingComplete(column, currentRendererElement);
}
}