We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

GridCellNumericRendererExt - Add VirtualKey as new value on edit

Thread ID:

Created:

Updated:

Platform:

Replies:

125134 Jul 24,2016 03:41 PM Jul 31,2016 09:48 PM UWP 3
loading
Tags: SfDataGrid
Brandon Hankins
Asked On July 24, 2016 03:41 PM

Hello,

I was able to successfully implement the GridCellNumericRendererExt class to allow for special characters to initiate editing of cells. However, I am unable to determine a way to set that special character as the new value on BeginEdit. Specifically, we have a requirement for a decimal field that allows values without a leading zero (i.e .75). While, the user can double click on the cell to enter BeginEdit and type .75, they are unable to type .75 when the cell is selected and BeginEdit has not started. They are able to do 0.75, but they will not accept this to satisfy the requirement. Is there a way to modify the GridCellNumericRendererExt so that it takes the special character that initiated the edit as the new value?

Steps to reproduce the problem:

1. Implement GridCellNumericRendererExt
2. On a page with SfDataGrid, select the cell you wish to edit WITHOUT entering edit mode
3. Being to type a decimal value with "." as the leading character

You will find that the cell only takes any keystrokes entered after the decimal has been pressed and ignores the decimal character.

Thanks,
Brandon

Jai Ganesh S [Syncfusion]
Replied On July 26, 2016 10:47 PM

Hi Brandon, 
 
You can achieve your requirement to show the special characters while you go to edit mode on the cell by overriding the  OnEditElementLoaded method like below, 
 
protected override void OnEditElementLoaded(object sender, RoutedEventArgs e) 
{ 
    var uiElement = ((DoubleTextBox)sender); 
    uiElement.ValueChanged += OnValueChanged; 
 
    uiElement.Focus(); 
 
    if ((this.DataGrid.EditorSelectionBehavior == EditorSelectionBehavior.SelectAll || this.DataGrid.IsAddNewIndex(this.CurrentCellIndex.RowIndex)) && PreviewInputText == null) 
    { 
        uiElement.SelectAll(); 
    } 
    else 
    { 
        if (PreviewInputText == null || char.IsLetter(PreviewInputText.ToString(), 0)) 
        { 
            var index = uiElement.Text.Length; 
            uiElement.Select(index + 1, 0); 
            return; 
        } 
        double value; 
        double.TryParse(PreviewInputText.ToString(), out value); 
        uiElement.Value = value; 
        uiElement.Text = PreviewInputText.ToString(); 
        var caretIndex = uiElement.Text.IndexOf(PreviewInputText.ToString(CultureInfo.InvariantCulture), StringComparison.Ordinal); 
        uiElement.Select(caretIndex + 1, 0); 
    } 
    PreviewInputText = null; 
} 
 
 
Regards, 
Jai Ganesh S 


Brandon Hankins
Replied On July 28, 2016 09:24 AM

This sample appears to be for WPF. We are using UWP. Thanks.

Jai Ganesh S [Syncfusion]
Replied On July 31, 2016 09:48 PM

Hi Brandon, 
 
We have used SfNumericTextBox for GridNumericColumn in UWP platform. In SfNumerictextBox the text is displayed based on the value not in PreviewInputText. So we regret to inform you that, in GridNumericColumn you cannot show the typed special character when begin edit. 
 
Regards, 
Jai Ganesh S 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;