This is a migrated thread and some comments may be shown as answers.

NumericInput doesn't work for cell editing?

11 Answers 253 Views
MaskedInput (Numeric, DateTime, Text, Currency)
This is a migrated thread and some comments may be shown as answers.
Sam
Top achievements
Rank 1
Sam asked on 30 Apr 2012, 02:07 AM
Hi,

I'm trying to use a RadMaskedNumericInput inside a RadGridView cell edit template. The main issue is that when I press return, the cell edit is not committed, ie, it just does nothing.

Previously we used a RadMaskedTextBox which accepts the enter keypress for committing the cell edit.

Is there a way to get the RadMaskedNumericInput to accept Enter to commit the cell edit? Shouldn't this just happen out of the box? 

We would like to be able to use the numeric input over the masked text box, but there are just too many deficiencies in its behaviour so far.

11 Answers, 1 is accepted

Sort by
0
Tina Stancheva
Telerik team
answered on 02 May 2012, 02:30 PM
Hi Sam,

It is indeed better to use the new MaskedInput controls instead of the RadMaskedTextBox control and this is why I'm sorry to hear that you've encountered issues with them. And this is why I want to encourage you to take advantage of the support ticketing system when encountering such issues, as it will allow us to assist you in overcoming them in a timely manner.

So let me get straight to your question - the 'enter' key issue is a bug and it is logged in our PITS where you can track its progress. We will do our best to fix it as soon as possible. But in the meantime you can implement a sample workaround by handing the RadMaskedNumericInput.KeyDown event and commit the RadGridView.Cell changes as soon as the Enter key is hit:
public MainPage()
{
    InitializeComponent();
 
    this.AddHandler(RadMaskedNumericInput.KeyDownEvent, new KeyEventHandler(OnKeyDown), true);
}
  
private void OnKeyDown(object sender, KeyEventArgs e)
{
  
    if (e.Key == Key.Enter)
    {
        e.Handled = true;
        myGridView.CommitEdit();
    }
}

Please give this a try and let us know if it helps or if you have more issues/questions.

Regards,
Tina Stancheva
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
vk
Top achievements
Rank 1
answered on 13 May 2012, 01:09 PM

Hi Sam,

In addition to the previous post I can share my experience with the MaskedInput controls when they are placed inside CellEditTemplates.To force the controls behave like common gridviewcells when pressing keys like Enter, Right (Left, Up, Down) arrows I came up with the following:

private void MaskedInput_KeyDown(object sender, KeyEventArgs e)
        {
            RadMaskedInputBase mib = sender as RadMaskedInputBase;
 
            if (e.Key == Key.Right)
            {
                if (mib.SelectionStart == mib.Text.Length)
                    SendCommandsToGridView(myGridView, RadGridViewCommands.MoveRight);
            }
            else if (e.Key == Key.Left)
            {
                if (mib.SelectionStart == 0)
                    SendCommandsToGridView(myGridView, RadGridViewCommands.MoveLeft);
            }
            else if (e.Key == Key.Up)
                SendCommandsToGridView(myGridView, RadGridViewCommands.MoveUp);
 
            else if (e.Key == Key.Down)
                SendCommandsToGridView(myGridView, RadGridViewCommands.MoveDown);
 
            else if (e.Key == Key.Enter)
                SendCommandsToGridView(myGridView, RadGridViewCommands.MoveNext);
             
        }
 
        void SendCommandsToGridView(RadGridView grid, ICommand whereToMoveCommand)
        {            
            grid.PendingCommands.Add(whereToMoveCommand);
            grid.PendingCommands.Add(RadGridViewCommands.SelectCurrentUnit);
            grid.PendingCommands.Add(RadGridViewCommands.BeginEdit);
 
            grid.ExecutePendingCommand();
        }

Also to overcome some validation issues (I'm using WCF RIA services and DataAnnotations for validating properties) I had to set some properties for MaskedInput controls other than their defaults... Here is an example:

<telerik:RadMaskedTextInput
     Value="{Binding DeclarationNumber, Mode=TwoWay,
                   ValidatesOnExceptions=False,
                   ValidatesOnDataErrors=False,
                   NotifyOnValidationError=False,
                   ValidatesOnNotifyDataErrors=False}"
     Mask="#########/####/######"
     UpdateValueEvent="LostFocus"
     AllowInvalidValues="True"
     IsClearButtonVisible="False"
     IsLastPositionEditable="False"
     SelectionOnFocus="SelectAll"
     SectionsNavigationMode="None"
     HorizontalAlignment="Stretch"
     Padding="2"                                                               
     KeyDown="MaskedInput_KeyDown"/>

Hope this helps.

0
vk
Top achievements
Rank 1
answered on 15 May 2012, 08:05 AM
I've just installed the 0514 hotfix (trial) and noticed that the above technique stopped working as expected. Now if I enter an incorrect value to a MaskedTextInput  or MaskedNumericInput control and press Enter the control notifies about the error. I change the value to be a correct one and press Enter (or Tab ) but the control continues to be in focus with error indication... I click next cell with mouse and it clears error and moves focus to the cell I clicked.
Got back to 0507 hotfix and everything works fine...
0
Tina Stancheva
Telerik team
answered on 17 May 2012, 02:39 PM
Hi Sam,

I prepared a sample solution trying to reproduce the issue. But I feel I might be missing something because I wasn't able to. Can you take a look at the solution I attached and let me know if it works for you or how it has to be modified to reproduce the issue? Thank you in advance.

All the best,
Tina Stancheva
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
vk
Top achievements
Rank 1
answered on 18 May 2012, 12:33 AM
Hi Tina,

I can't upload files so could you take a look at the solution located here ?

issue #1
- click on the insert new row panel
- press the enter key to accept a default datetime value for the first field
- change the value to the correct one (today's date)
- press the enter key again and notice that you can't leave the field by pressing keys, but you can easily leave it with a mouse click on any other cell...

issue #2
- select the decl weight column (don't enter the edit mode) and type the value of 1
- press the enter key and notice that the value reverted to the previous one as if AllowInvalidValues is false, but it is true...

issue #3
- select the decl weight column (enter the edit mode) and type the value of 1
- press the enter key and notice that the cell shows a validation error but you can edit another cell. If you used a common textbox as the editting control for the cell it would not allow to lose focus untill you correct the value to a valid one... It would be the expected behaviour.

Thanks.
0
Tina Stancheva
Telerik team
answered on 22 May 2012, 03:23 PM
Hello Valentin,

Thank you for sending a sample solution and posting elaborate steps to reproduce all issues. However, as we will need more time to investigate them, I will keep you posted on the progress.

All the best,
Tina Stancheva
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Tina Stancheva
Telerik team
answered on 29 May 2012, 09:00 AM
Hello Valentin,

Just to follow up on this, I wanted to let you know that in order to get over the first and the third issue, you need to remove the MaskedInput.UpdateValueEvent settings from the RadMaskedInput definitions and instead define in the DataMemberBinding property binding UpdateSourceTrigger to Explicit.

As for the second issue, it a known bug caused by the RadGridView.EditTriggers default settings. Basically when the EditTriggers is set to Default or TextInput, the RadMaskedInput controls consider the first entered key as simply entering an edit mode and this is why their value starts changing only after entering another character. This issue is logged in our PITS where you can track its progress.   

I updated the solution you sent to demonstrate how to modify the definitions of the controls to get over the described issues.

Regards,
Tina Stancheva
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
vk
Top achievements
Rank 1
answered on 30 May 2012, 05:56 AM
Hi Tina,

Thank you very much!
0
Hitesh
Top achievements
Rank 1
answered on 10 Nov 2012, 05:27 PM
Hi Tina,

I have similar problem like below

As for the second issue, it a known bug caused by the RadGridView.EditTriggers default settings. Basically when the EditTriggers is set to Default or TextInput, the RadMaskedInput controls consider the first entered key as simply entering an edit mode and this is why their value starts changing only after entering another character. This issue is logged in our PITS where you can track its progress.   

any idea when it will be resolved?
0
Hitesh
Top achievements
Rank 1
answered on 10 Nov 2012, 05:57 PM
is any workaround solution without changing EditTriggers="TextInput" in RadGridView, which is indeed?
0
Petar Mladenov
Telerik team
answered on 15 Nov 2012, 07:59 AM
Hi Hitesh,

 There is a workaround which uses events in code behind, for example like so:

private void RadMaskedNumericInput_GotFocus(object sender, System.Windows.RoutedEventArgs e)
        {
            RadMaskedNumericInput numeric = sender as RadMaskedNumericInput;
            double? currVal = numeric.Value;
            numeric.Value = 123d;
            numeric.Value = currVal;
        }
plus using the GridView.KeyDown to store the value you wish to set on the MaskdInput by pressing a digit ... But this is far away from elegant code and we strongly suggest you to avoid such workarounds. Is setting the EditTriggers to "TextInput" mandatory for you ?

Regards,
Petar Mladenov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
MaskedInput (Numeric, DateTime, Text, Currency)
Asked by
Sam
Top achievements
Rank 1
Answers by
Tina Stancheva
Telerik team
vk
Top achievements
Rank 1
Hitesh
Top achievements
Rank 1
Petar Mladenov
Telerik team
Share this question
or