Nativescript-ui-feedback: RadDataForm bug with the Number editor when calling validateAndCommit

Created on 27 Feb 2018  路  4Comments  路  Source: ProgressNS/nativescript-ui-feedback

Did you verify this is a real problem by searching Stack Overflow?

_Yes_

Tell us about the problem

I have a source object with some attributes (including, say, age,). I use it to populate a dataform and the editor of age is Number. Initially age=null.
After I change the value of age via the UI and press a button, the validateAndCommitAll() of the DataForm is called. The returned promise resolves with true. However the source object's age is populated with an empty object - {}. The dataform.editedObject's age is still null.
I set up the dataform via metadata.

Which platform(s) does your issue occur on?

Android

Please provide the following version numbers that your issue occurs with:

  • Progress NativeScript UI version: 3.5
  • CLI: 3.4.0
  • Cross-platform modules: 3.4.0
  • Runtime(s): 3.4.0

Please tell us how to recreate the issue in as much detail as possible.

I forked the ui-samples repo - here's a commit with the changes I've made (single additional commit contains all changes I've made).
Start the app, go to DataForm, Properties JSON. Enter some age and, whilst the cursor is still on the age, press Go - observe the console.
EDIT forgot to mention that if you first unfocus the number field, and then initiate the validateAndCommit, the age attribute seem to be populated correctly.

Is there code involved? If so, please share the minimal amount of code needed to recreate the problem.

https://github.com/jorotenev/nativescript-ui-samples/

I'll be super thankful for suggestions about workarounds for this problem.

Best,
Joro

dataform

Most helpful comment

I have an interesting issue related this 'Number' TKPropertyEditor type.
When i type 10 digits of numbers , its ok and i can pass the field with no problem.
But when i type larger then 10 digits, it clears my field.

Btw it fails android only, in ios it works.

All 4 comments

I found a workaround. Instead of reading the number property directly (which will result in the "empty object" from above, which apparently is not that empty), use Number(String(property).

Note, that adding any validators on the property (e.g. RangeValidator) will be problematic - the validator will receive the object value. Thus, for the Number properties I validate manually before calling validateAnCommitAll().

Using the example repo from above, with commit&validationMode of the form set to Manual,

export function tapped() {
    //what the user has entered
    let age = dataform.getPropertyByName("age").valueCandidate; 
    // do manual validation here http://docs.telerik.com/devtools/nativescript-ui/Controls/NativeScript/DataForm/Validation/dataform-validation-custom#manual-validation    
   // and if it passes, call the validateAndCommitAll
   dataform.validateAndCommitAll().then((ok) => { // validate and commit will work as expected for all 
    properties except for `age`, because `age` has Number editor
        if (ok) {
            // person now has all its properties updated due to the validateAnd*Commit*All.
           if (age) {
             person.age = Number(String(age)) // that's the workaround. age is some object of some number-like type but apparently its `toString()` works
           }
        // use the updated `person`
        }
    })
}

I hit the same or at least very similar problem:

  1. I have a Number field in my dataform, with value initially set to null. The field also has a validator connected with it.
  2. After a user type a number into the field and then clicks a button that executes validateAndCommitAll(), the validator is run but it receives the null value, instead of the number typed by the user.
  3. If the user then change the number and clicks the button again, the validator is run with the most recent number, as it should be.

@NickIliev What is the reasoning behind this bug getting closed?

I have an interesting issue related this 'Number' TKPropertyEditor type.
When i type 10 digits of numbers , its ok and i can pass the field with no problem.
But when i type larger then 10 digits, it clears my field.

Btw it fails android only, in ios it works.

I have an interesting issue related this 'Number' TKPropertyEditor type.
When i type 10 digits of numbers , its ok and i can pass the field with no problem.
But when i type larger then 10 digits, it clears my field.

Btw it fails android only, in ios it works.

I face the same issue. any solutions fot this?

Was this page helpful?
0 / 5 - 0 ratings