_Yes_
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.
Android
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.
https://github.com/jorotenev/nativescript-ui-samples/
I'll be super thankful for suggestions about workarounds for this problem.
Best,
Joro
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:
Number field in my dataform, with value initially set to null. The field also has a validator connected with it.validateAndCommitAll(), the validator is run but it receives the null value, instead of the number typed by the user.@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?
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.