Completed
Last Updated: 06 Dec 2021 13:17 by ADMIN
Release LIB 2021.3.1206 (6 Dec 2021)
ADMIN
Dinko
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;
    }
}
8 comments
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.