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

Update Bound Property on Lost Focus

1 Answer 65 Views
MaskedInput (Numeric, DateTime, Text, Currency)
This is a migrated thread and some comments may be shown as answers.
WILLIAM
Top achievements
Rank 1
WILLIAM asked on 07 Feb 2013, 04:00 PM
I'm trying to use a NumericInput control and can't seem to figure out how to get it to behave properly.  Even though I have UpdateValueEvent="LostFocus", it doesn't always update the bound property.  Setting UpdateValueEvent="PropertyChanged" works the same way.  In order to Update the value to 1, I have enter 0001.  Also, if I clear the text, the value does not update to blank

I have RadGrid and View that are bound to the same object.  The bound property for this control is int?

See my attached screen shots:
#1 Shows a new record being entered and I'm about to change the "From" value.
#2 Shows that I entered a value of 1234 and tabbed to Year Graduated.  (Expected Behavior)
#3 Shows that I changed the value in "From" to 1 and tabbed to Year Graduated.  However, the value in the grid did not update, and if I inspect bound object, it is still set to 1234 even though the value on the form has been changed to 1.
#4 Shows that I have enter 0001 to update the value to 1.
#5 Shows that I have "From" value has been cleared, but the value in the grid did not change

How do I set this control up to be able to:
1. Enter any positive (up to 4 digits)
2. Allow the user to clear/blank out/remove an existing value
3. No matter what, when the control loses focus, the underlying bound property is updated.

Here is how I currently have the control configured.
<telerik:RadMaskedNumericInput Name="uxFrom" Mask="#4" TextMode="MaskedText"
                               InputBehavior="Insert" SelectionOnFocus="CaretToBeginning"                                               
                               UpdateValueEvent="LostFocus" IsClearButtonVisible="False"
                               AutoFillNumberGroupSeparators="False"
                               Grid.Row="3" Grid.Column="5" Grid.ColumnSpan="1" Margin="0,0,4,0"/>

Thanks for your help!

1 Answer, 1 is accepted

Sort by
0
Petar Mladenov
Telerik team
answered on 12 Feb 2013, 03:38 PM
Hi WILLIAM,

 I cannot see your Value property two-way bound to a ViewModel's property. I guess you need the following configuration:
MaskedNumericInput.Value <-2 way bound --> double property from your ViewModel -->bound to GridView Cell
For a successful result, you have to ensure:

  • two-way binding between Value and the double property from your viewmodel
  • OnPropertyChanged() to fire when the ViewModel's Property is re-set, changed (this will update the value displayed in the GridView)
  • the property in the VM should be nullabale double (double?), this way when you press the clear button the value in the viewmodel will be null
Let us know if this help you proceed further or not.
All the best,
Petar Mladenov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

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