Change an Entity's value based on the value of another Entity

Thread is closed for posting
2 posts, 0 answers
  1. Vince
    Vince avatar
    3 posts
    Member since:
    Apr 2017

    Posted 10 May 2017 Link to this post

    Is it possible to change the value of an Entity when another Entity changes? For instance, in the example here, it seems intuitive that increasing the number of tickets should increase the price. However, this is not the behavior that occurs in the example currently. Is this behavior currently possible to implement? 
  2. nikolay.tsonev
    nikolay.tsonev avatar
    340 posts

    Posted 11 May 2017 Link to this post


    First of all, thank you for your interest in UI for NativeScript.

    For this case, at the moment the possible way to change the value of the field related to the value of the other one is to change the source of the component.
    You could handle DataForm propertyCommittedEvent and to update the field value, by creating a new object for the DataForm source. For example:

    <StackLayout tkExampleTitle tkToggleNavButton>
        <RadDataForm  #myCommitDataForm (loaded)="onLoaded()" [source]="user" commitMode="immediate" height="400" (propertyCommitted)="onPropertyCommitted()">
            <TKEntityProperty tkDataFormProperty name="number1" index="0"></TKEntityProperty>
            <TKEntityProperty tkDataFormProperty name="number2" index="1">
                <TKPropertyEditor type="number"></TKPropertyEditor>

    import { Component, OnInit, ViewChild } from "@angular/core";
    import { CommitMode } from "nativescript-telerik-ui-pro/dataform";
    import { RadDataFormComponent } from "nativescript-telerik-ui-pro/dataform/angular";
    import { SegmentedBarItem, SelectedIndexChangedEventData } from "tns-core-modules/ui/segmented-bar";
    import * as timerModule from "tns-core-modules/timer";
    class User {
        public number1: number = 0;
        public number2: number =0;
        constructor() {
        selector: "tk-dataform-commit-modes",
        templateUrl: "dataform-commit-modes.component.html"
    export class DataFormCommitModesComponent implements OnInit {
        private _commitMode;
        private _isEnabled: boolean;
        private _segmentedBarItems: Array<SegmentedBarItem>;
        private user: User;
        private _result: string;
        constructor() {
        ngOnInit() {
            this.user = new User();
        @ViewChild('myCommitDataForm') myCommitDataFormComp: RadDataFormComponent;
        get commitMode() {
            return this._commitMode;
        public onLoaded() {
        public onPropertyCommitted(args) {
        public updateFields() {
            if (this.myCommitDataFormComp.dataForm.editedObject) {
                this._result = null;
                this._result = this.myCommitDataFormComp.dataForm.editedObject;
                var object = JSON.parse(this._result);
                this.user = new User();

    You could also keep track on this feature request for supporting two-way binding, which will be available for some of the next UI for NativeScript releases and will provide an easy way to change the value of a specific Entity.

    Hope this information helps.
    Telerik by Progress
    Did you know that you can open private support tickets which are reviewed and answered within 24h by the same team who built the components? This is available in our UI for NativeScript Pro + Support offering.
Back to Top