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

Paste value with greater length than mask allows

7 Answers 133 Views
MaskedInput (Numeric, DateTime, Text, Currency)
This is a migrated thread and some comments may be shown as answers.
Phillip
Top achievements
Rank 1
Phillip asked on 20 Jun 2016, 10:30 AM

Hallo everyone,

in an actual project I have the following problem. I use:

-RadMaskedNumericInput* 

-MaskToken (For Example: #9.2)

The user can't write more than 11 numeric digits in it. Thats ok, but if he copy & paste a value with more digits in it, it appears in the 

DataRow behind (See attached file). Even if AllowInvalidValues equals to false. 

Its a workaround to prove the length by every input,  but thats not really what the developer expects. In a business application with over hundreds of elements a developer will not check everytime if the length of the value is correct, so this can't be the right way.

*Don't know if it appears by other "MaskedInput"-controls

7 Answers, 1 is accepted

Sort by
0
Petar Mladenov
Telerik team
answered on 20 Jun 2016, 11:19 AM
Hello Phillip,

RadMaskedNumericInput is designed to work with doubles and RadMaskedCurrencyInput is designed to work with decimals which have higher precision rates. From the picture it seems you need to display a currency. Is it possible for you to try a CurrencyInput  (bound to decimal value) instead of NumericInput with doubles ? Let us know if you experience any similar issue with CurrencyInput.

Regards,
Petar Mladenov
Telerik
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
0
Phillip
Top achievements
Rank 1
answered on 20 Jun 2016, 12:25 PM

Hi Petar,

we (colleagues from the company I work) tried  it with every MaskedInputControl. But with every Control where we pasted a value that shouldn't be allowed cause of the MaskToken, was then in the DataRow, like it is shown in the picture. :( 

 

-Phillip

colleagues
colleagues
colleagues
colleagues
colleagues
colleagues
colleagues
0
Petar Mladenov
Telerik team
answered on 21 Jun 2016, 07:28 AM
Hello Phillip,

From the snapshots I am no sure what is the copied value. Could you please elaborate more on he exact steps your perform? For example you copy "123456" and you paste it in MaskedNumericInput with Mask="#9.2" when the caret is on index  x and the value currently is y. Also let us know what you expect to happen - which value you expect to be pasted / coerced. Thank you in advance for your cooperation.

Regards,
Petar Mladenov
Telerik
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
0
Phillip
Top achievements
Rank 1
answered on 21 Jun 2016, 01:27 PM

Hello Petar,

Here is a step by step explaination:

1.) Create RadMaskedNumericInput with a MaskToken (using MVVM for example) :

<telerik:RadMaskedNumericInput Value="{Binding  Path=Test,  Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True}" Mask="#4.2" MinWidth="100" IsClearButtonVisible="False" Margin="0,10,0,0"/>

 

2.) Create Proberty "Test":

private decimal _Test;
 
    public decimal Test
    {
       get
       {
          return _Test;
       }
       set
       {
          if (_Test != value)
          {
             _Test = value;
             OnPropertyChanged();
          }
 
       }
    }

 

3.) Start the engine

Here are the description for the attached files:

Bild1 = Start the programm, look at this amazing and beautiful RadMaskedNumericInput element

 

Bild2 = Write the following number in it: 2.345,67 - Yeah it works. Only this number of letters is possible.

 

Bild3 = Get a number with more letters. For Example: 12.345,67

 

Bild4 = Make a breakpoint by the setter method of the proberty and  paste the new number into the field - tadaaa the problem appears = 12.345,67 is in the value. More than allowed by the MaskToken

 

Bild5 = But in the field you see only this number: 2.345,67

 

That has nothing to do with a "Numeric" or "Decimal" Input. This happens even with a string and a RadMaskedTextInput.

In my opinion the expected behavior is that the field only inputs this number  2.345,67 and cuts off the 1. (JMO)

Hopefully this helps you.

 

Greets,

Phillip Kalusek

0
Accepted
Petar Mladenov
Telerik team
answered on 22 Jun 2016, 07:42 AM
Hi Philip,

By pasting a number in MaskedInput control or TextBox , at first in the setter of the bound property you will receive the number / string you are trying to paste / input. It's totally expected for this setter to fire, because the Value of the RadMaskedInput control is two-way bound and passes several coercing / parsing processes. Actually the produced value will be just the one you expect 2345.67 - the setter will finally fire with the 2345.67 and the Value property of the control will hold the number 2345.67. If you need detection that Value is changed only with the final Value of this whole process - you can subscribe to ValueChanged event of the RadMaskedNumericInput.

Regards,
Petar Mladenov
Telerik
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
0
Phillip
Top achievements
Rank 1
answered on 22 Jun 2016, 12:32 PM

Hi Petar,

thanks for anwsering my question.

So when I write something into the field the setter method fires only one time cause of the masktoken but by copy and paste it fires twice cause the masktoken comes then at second place...!?!? that isn't gonna make it easier... :( And it isn't a good solution for this problem. How should I handle the inputs with this behavior by over hundres of elements in the application? Always split the Int/String etc.? mmmmmhhhh, no, not good.

The Problem is that many elements with a asynchrone method behind, search in the database for a correct entry. And this gives me/the user everytime a error mesage  cause the field in the database has the same mask...

And to set the timer for the asynchrone method later than it is right now, shouldn't be a solution, too.

0
Petar Mladenov
Telerik team
answered on 23 Jun 2016, 08:04 AM
Hello Phillip,

You scenario seems very complex and we miss many details from its implementation. However, we are almost sure there is a possible solution that is not dependent on the number of times setter fires.

You can try UpdateSourceTrigger = LostFocus on the Binding or Mask="dddd.##" if your architectureallows this.

Regards,
Petar Mladenov
Telerik
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Tags
MaskedInput (Numeric, DateTime, Text, Currency)
Asked by
Phillip
Top achievements
Rank 1
Answers by
Petar Mladenov
Telerik team
Phillip
Top achievements
Rank 1
Share this question
or