Nativescript-ui-feedback: DataForm boolean field not changing

Created on 16 Apr 2018  路  8Comments  路  Source: ProgressNS/nativescript-ui-feedback

Please take a minute to read our NativeScript Code of Conduct before proceeding with posting issues or discussing. The purpose of this guide is to make communication and cooperation within our forums a pleasure for you and the other members.

Please, provide the details below:

Did you verify this is a real problem by searching the NativeScript Forum?

_Yes_

Tell us about the problem

Same as this: https://github.com/telerik/nativescript-ui-feedback/issues/324

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.2
  • CLI: 3.4.3
  • Cross-platform modules: 3.4.1
  • Runtime(s): tns-android

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

https://discourse.nativescript.org/t/raddataform-switch-not-updating-boolean/5486

bug dataform

Most helpful comment

I confirm the issue with nativescript-ui-dataform 3.5.2 on Android. As described by @chrisdrobison, the boolean values managed by property editors of type Switchare never updated in original object.
As temporary workaround, I manually parse the JSON object returned by dataForm at every property change: const formData = JSON.parse(dataForm.editedObject). The boolean fields of formData are correctly updated, so I can manually update the original object that is bound to dataForm.

All 8 comments

Hi @chrisdrobison,
I tested your scenario with the latest NativeScript(4,0) and nativescript-ui-dataform(3.5.2), however, I was unable to recreate an issue with the returned DataForm values. For your convenience, I am attaching a sample project. Please review it and make the needed changes, which will allow us to recreate the issue.
Archive.zip

@tsonevn I've taken your example and added a button. I'm seeing the committing and committed messages showing correctly, but the boolean never actually gets committed back to the original object that is bound to the data form. After you change the switch value, hit the button and you will see what I'm talking about.

raddataform-example.zip

I've also tried putting something like the following in the committed event:

        if (args.propertyName === "enabled") {
            this.notificationSetting.enabled = !this.notificationSetting.enabled;
        }

But, the boolean property always gets reset to false.

@tsonevn Any word on this?

I confirm the issue with nativescript-ui-dataform 3.5.2 on Android. As described by @chrisdrobison, the boolean values managed by property editors of type Switchare never updated in original object.
As temporary workaround, I manually parse the JSON object returned by dataForm at every property change: const formData = JSON.parse(dataForm.editedObject). The boolean fields of formData are correctly updated, so I can manually update the original object that is bound to dataForm.

Hi all,
I will check the attached project by @chrisdrobison and will provide more info on the issue.

I have checked the case and found that this issue seems to be related to the missing feature in the RadDataForm. At this getting and setting the DataForm Entity value by accessing the source object directly is not supported. We have a feature request logged in this issue. You can keep track on it for further info.
In the meantime, you can use the editedObject as @alexmeia already suggested.

I managed to reproduce the issue in this sample. I console.logged the source object in an onPropertyCommitted event handler:

    public onPropertyCommitted(args: DataFormEventData) {
        console.log(this.ticketOrder);
    }

and attached it to the form:

When I ran the example every change in the editors resulted in a change in the source object, except the changes in the switch editor - the value in the source object always remained false.

Was this page helpful?
0 / 5 - 0 ratings