RadDataForm how to update a value at runtime


#1

Hi,
I’m trying to update a value of an attribute in a RadDataForm, but failing miserably.
I took the example from the sdk->dataform->getting started and added a button. When pressing the button I change the persons name from John to Luke. But nothing happens on the editor. So I tried to get the editor and change the value there. Nothing happens. I tried reloading the dataform. No change. Am I missing something fundamental here?

This is what I’ve changed on the example:

person-model.js

“use strict”;
Object.defineProperty(exports, “__esModule”, { value: true });
// >> dataform-person-view-model
var observable_1 = require(“tns-core-modules/data/observable”);
var PersonViewModel = (function (_super) {
__extends(PersonViewModel, _super);
function PersonViewModel() {
var _this = _super.call(this) || this;
_this.person = new Person(“John”, 23, "john@company.com", “New York”, “5th Avenue”, 11);
return _this;
}
Object.defineProperty(PersonViewModel.prototype, “person”, {
get: function () {
return this.get("_person");
},
set: function (value) {
this.set("_person", value);
},
enumerable: true,
configurable: true
});
PersonViewModel.prototype.changeData = function() {
console.log(“change”);
this.person.name=“Luke”;
}
return PersonViewModel;
}(observable_1.Observable));
exports.PersonViewModel = PersonViewModel;
var Person = (function () {
function Person(name, age, email, city, street, streetNumber) {
this.name = name;
this.age = age;
this.email = email;
this.city = city;
this.street = street;
this.streetNumber = streetNumber;
}
return Person;
}());
exports.Person = Person;

getting-started.xml

<navigation:ExamplePage xmlns:navigation=“navigation/example-page” loaded=“onPageLoaded"
xmlns:df=“nativescript-pro-ui/dataform” xmlns=“http://www.nativescript.org/tns.xsd”>

<df:RadDataForm id=“myDataForm” source=”{{ person }}" />


</navigation:ExamplePage>


#2

You can refer these samples to learn how to use RadDataForms :slight_smile:


#3

Hi rkl_de, have you resolved your problem? I have the same requirement.
I can’t update the view unless i use the custom editor.

BTW, i use angular2+nativescript


#4

Hmm, this has been awhile… but I used the dataform propertyCommited event to change the value I needed.