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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

GridCellNumericRendererExt - Add VirtualKey as new value on edit

Thread ID:





125134 Jul 24,2016 07:41 PM UTC Aug 1,2016 01:48 AM UTC UWP 3
Tags: SfDataGrid
Brandon Hankins
Asked On July 24, 2016 07:41 PM UTC


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.


Jai Ganesh S [Syncfusion]
Replied On July 27, 2016 02:47 AM UTC

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; 
    if ((this.DataGrid.EditorSelectionBehavior == EditorSelectionBehavior.SelectAll || this.DataGrid.IsAddNewIndex(this.CurrentCellIndex.RowIndex)) && PreviewInputText == null) 
        if (PreviewInputText == null || char.IsLetter(PreviewInputText.ToString(), 0)) 
            var index = uiElement.Text.Length; 
            uiElement.Select(index + 1, 0); 
        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; 
Jai Ganesh S 

Brandon Hankins
Replied On July 28, 2016 01:24 PM UTC

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

Jai Ganesh S [Syncfusion]
Replied On August 1, 2016 01:48 AM UTC

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. 
Jai Ganesh S 


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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon 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.Close Icon