[Vuejs]-RadDataForm update example

0๐Ÿ‘

You just need to add a watcher to a local property, i recommend using mapState from Vuex.

You can have something like this:

  computed: mapState({
    record: this.$store.getters.record;
  })

And also a watcher that sets a callback to a function, based on if a value has changed or not.

  watch: {
    record: function () {
     // something to run when record changes
    }

In summary, you have a local mapped variable from your store and a watcher that acts on whether the information has changed or not. Hope this helps

See: MapState Helper
See: Computed properties and watchers

๐Ÿ‘คLuis Maldonado

0๐Ÿ‘

Ok, I found the answer. This is not documented anywhere I can find in the nativescript/vue docs. I found: RadDataForm Commit Documentation. So, using that, I modified to (keeping mapState from Luis.) I added:

v-on:propertyCommitted=โ€saveโ€ to RadDataForm

So, this works:

 `<StackLayout>
            <StackLayout orientation="vertical" backgroundColor="lightgray">
             <RadDataForm 
                :source="record"
                 v-on:propertyCommitted="save"/>
   </StackLayout>
   <script>
    export default {
        data() {}
        },
        methods:{
         save(){
             console.log('save')
            }, 
        }
        computed: mapState({
        record(state){
            return record = this.$store.getters.record;
        }
     };`
๐Ÿ‘คshane elliott

0๐Ÿ‘

Here is a more detailed answer for this. obviously, I would set the store value in the save function.

    <StackLayout>
            <StackLayout orientation="vertical" backgroundColor="lightgray">
             <RadDataForm 
                id="myDataForm"
                :source="record"
                 v-on:propertyCommitted="save"/>
   </StackLayout>
   <script>
    import { mapState } from 'vuex'
    import { getViewById } from "tns-core-modules/ui/core/view";
    export default {
        data() {}
        },
        methods:{
         save(){
            console.log('save')
            let data = args.object
            var dataform = getViewById(data, "myDataForm");
            console.log(dataform.editedObject)//<--updated Data Here
            }, 
        }
        computed: mapState({
        record(state){
            return record = this.$store.getters.record;
        }
     };
๐Ÿ‘คshane elliott

Leave a comment