Completed
Last Updated: 21 Feb 2022 15:13 by Scott Waye
Release LIB 2021.3.1206 (6 Dec 2021)
ADMIN
Dinko | Tech Support Engineer
Created on: 04 Apr 2016 12:48
Category: MaskedInput
Type: Bug Report
4
MaskedInput: Value property is not correctly updated when Mask=""(no-mask) and UpdateValueEvent is set to LostFocus
You have the following scenario:

The UpdateValueEvent property is set to "LostFocus". You have bound the Value property of the control to a property from your ViewModel. 


When this property is changed programmatically from negative to positive several times, the Value property of the control isn't updated correctly.

It stays negative when it must stay positive.


Workaround (if applicable):
You can change the UpdateValueEvent property to "PropertyChanged" 

Other Possible workaround (if the bound property is named "Sum")

private void radMaskedNumericInputSum_ValueChanging_1(object sender, Telerik.Windows.Controls.MaskedInput.RadMaskedInputValueChangingEventArgs e)
{
    if (this.Sum != (double)e.NewValue)
    {              
        e.Handled = true;
    }
}
15 comments
Scott Waye
Posted on: 21 Feb 2022 15:13

Martin,

Thank you for the response and the links.

ADMIN
Martin Ivanov
Posted on: 21 Feb 2022 11:04

Hello Scott,

Please excuse me for the delay. There is a feature request to allow entering decimal values without 0 (like .4). About the decimal point and the masked input, this doesn't work because by default the no-mask values are considered as integer input while typing (unless you preset the value to a decimal one). To allow this, you can set the FormatString property of the masked input control. For example:

 <telerik:RadMaskedCurrencyInput FormatString="F2"/>

If you prefer, a non-static format string, you can check the DynamicFormatString SDK example.

Regards,
Martin Ivanov
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

ADMIN
Martin Ivanov
Posted on: 10 Feb 2022 13:23

Hello Scott,

Thank you again for the feedback. Working on it and will get back to you within the next couple of days with more information on this.

Regards,
Martin Ivanov
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Scott Waye
Posted on: 03 Feb 2022 13:44

Thanks Martin,

 

I admit that I forgot about that attached property.  However the same problem exists for the decimal point.  In a UK or US culture where "." is used as the decimal point, on focusing a MaskedInput box you cannot type "." followed by "4" and get 0.4, you get 4.  Can you add a similar attached property so numbers like 0.4 can be entered in this way?  You can use the same solution here to see what I mean.  Typing "0", then ".", then "4", also results in 4 not 0.4: this seems wrong to me.

 

Thanks

ADMIN
Martin Ivanov
Posted on: 03 Feb 2022 10:20

Hello Scott,

We've reviewed the project and this seems as an expected behavior. In order to change it and allow minus when the Value is still null, you will need to set the MaskedInputExtensions.AllowMinusOnNullValue attached property to True.

xmlns:maskedInput="clr-namespace:Telerik.Windows.Controls.MaskedInput;assembly=Telerik.Windows.Controls.Input"

 <telerik:RadMaskedCurrencyInput maskedInput:MaskedInputExtensions.AllowMinusOnNullValue="True"/>        

Can you try this and let me know if it helps?

Regards,
Martin Ivanov
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

ADMIN
Martin Ivanov
Posted on: 01 Feb 2022 11:39

Hello Scott,

Thank you for the report. We are going to check what is happening and see how to proceed in the next few days.

Regards,
Martin Ivanov
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Scott Waye
Posted on: 25 Jan 2022 12:16
I don't believe the problem of entering negative numbers is fixed, but I don't know if you want a separate issue for it.  I'm using 2022.01.11 and you cannot press "-", then "1" and get -1 in the box.  Have attached the solution.
ADMIN
Martin Ivanov
Posted on: 02 Dec 2021 23:01

Hello Scott,

I've logged a separate item for this issue since it is a bit different and related it to this item in the internal backlog. To work this around, you can override the HandleSubstractKey() method of the RadMaskedInput control and manually add the minus sign to the text.

protected override bool HandleSubstractKey()
{
	if (this.Value == null)
	{
		this.IsNegativeValue = !this.IsNegativeValue;
		var tb = this.FindChildByType<PreviewInputTextBox>();
		if (!string.IsNullOrEmpty(tb.Text))
		{
			if (this.IsNegativeValue)
			{
				tb.Text = "-" + tb.Text;
			}
			else
			{
				tb.Text = tb.Text.Substring(1);
			}
		}
	}
	else
	{
		base.HandleSubstractKey();
	}
   
	return true;
}

Regards,
Martin Ivanov
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

ADMIN
Martin Ivanov
Posted on: 02 Dec 2021 15:24

Hello Scott,

Thank you for the project and the additional information.

This case originates from a ticket raised by another user with a issue different than the one in the last project and the ticket you mentioned. If I am correct, you mean the one with the custom RadGridView's GridViewAmountColumn. Anyway, I will further research this and get back to you within the next few hours with more information on the topic.

Regards,
Martin Ivanov
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Scott Waye
Posted on: 25 Nov 2021 18:07
The workaround we suggest to out users, is to enter the value, tab out, tab back in, then you can press the "-".
Scott Waye
Posted on: 25 Nov 2021 18:05
As a bit of background, I think this task originates from a support ticket I raised and the fact that it is for RadMaskedCurrencyInput  has got lost.
Scott Waye
Posted on: 25 Nov 2021 18:04

Unfortunately not.  It's ok in with RadMaskedNumericInput but not with RadMaskedCurrencyInput when bound to a nullable field.  Try the attached (modified to use .netcore), run it, focus the box (which is completely empty, does not start with a "0", enter 1, then press "-".  You will note that the "-" is ignored and you cannot enter a negative number.

 

Thanks.

ADMIN
Martin Ivanov
Posted on: 25 Nov 2021 15:28

Hello Scott,

An alternative solution is to override the OnPropertyChanged() method of RadMaskedNumericInput and in case the Value property is changed to update the protected IsNegativeValue property. 

public class CustomMaskedNumericInput : RadMaskedNumericInput
{
	protected override void OnPropertyChanged(DependencyPropertyChangedEventArgs e)
	{
		if (e.Property.Name == "Value")
		{
			this.DetermineIsNegativeValue();
		}
		base.OnPropertyChanged(e);
	}

	private void DetermineIsNegativeValue()
	{
		if (this.Value != null)
		{
			if (this.Value < 0)
			{
				this.IsNegativeValue = true;
			}
			else if (this.Value > 0)
			{
				this.IsNegativeValue = false;
			}
			else
			{
				bool allowMinus = MaskedInputExtensions.GetAllowMinusOnZeroValue(this);
				if (!allowMinus && this.IsNegativeValue)
				{
					this.IsNegativeValue = false;
				}
			}
		}
		else
		{
			this.IsNegativeValue = false;
		}
	}
}

You can also see this approach shown in the attached project. Can you please try it and let me know if it helps?

Regards,
Martin Ivanov
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Scott Waye
Posted on: 18 Nov 2021 18:38
The suggested "possible" workaround does not work: pressing the minus key still has no effect.
Scott Waye
Posted on: 02 Jun 2016 16:19
This is annoying that Telerik are not taking this more seriously.  Problem seems to be in CoerceValueOverride where the IsNegativeValue is incorrect.