DataForm with nested object

4 posts, 0 answers
  1. Vamsi
    Vamsi avatar
    4 posts
    Member since:
    May 2017

    Posted 15 May Link to this post

    Hi

    Just wondering if its possible to display data from the nested object in the DataForm? for example

    export class Patient{

         id:number;

         name:string;

         constructor(id:number, name:string){

              this.id=id;

              this.name=name;

         }

    }

    export class PatientQuestionnaire{

          patient:Patient;

          question1:string;

         constructor(patient:Patient, questions:string){

              this.patient=patient;

              this.question1=question1;

         }

    }

     

    Is it possible to use PatientQuestionnaire as source entity and display the "name" from the patient class?. 

    I've tried to use something like this TKEntityProperty name="patient.id", but its not getting displayed on the screen, only "questions1" field is getting displayed on the screen.

     

    Thank you

    Vamsi

  2. Nikolay Iliev
    Admin
    Nikolay Iliev avatar
    295 posts

    Posted 15 May Link to this post

    Hello Varnsi,

    I have researched your example and what is happening is that you are trying to pass complex jsonObject yo your editor which is not supported by RadDataForm.and its editors.

    To resolve such cases we can either normalize our source or use value converters depending on our business logic. Example on what value converters are for and how to implement them can be found here, and the documentation section about editors converters can be found here.
    In the example above we have two different models - TicketOrder and Movie. In our view model, we have three separate properties which will be later used as a source or our DataForm and for the editor that will handle the converted values. Notice that the source for our RadDataForm is the ticketOrder while at the same time the valueProvider (as source) for our editor with name movie is the property movieNames This is the part where as we have Array of movies (objects) we have to provide something like movie.name  which will throw with the known error about value converters. So instead of passing the dot syntax, we are using the converters function to tell that name="movie" using the converters here.

    As a conclusion what we need is to change the valueProvider and make sure that we are not passing jsonObject but a converted value to our picker name property using the converter fallbacks convertFrom and convertTo

    Regards,
    Nikolay Iliev
    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.
  3. Vamsi
    Vamsi avatar
    4 posts
    Member since:
    May 2017

    Posted 15 May Link to this post

    Thank you Nikolay,

    Just wanted to know if its possible, as you said its not possible at the moment we took alternative approach, we have entity class with inner class, that solves my problem, but nested object support might be a useful feature to have going forward.

    Regards,

    Vamsi

  4. Nikolay Iliev
    Admin
    Nikolay Iliev avatar
    295 posts

    Posted 16 May Link to this post

    Hey Varnsi,

    Yes, it is possible but only when using the converters functions for which you should provide your own custom implementation for the conversion process. Of course, if you think that supporting this out-of-the-box would be a good add-on you can log a feature request here where the community and our developers will take it into consideration.

    Once again thank you for your interest in NativeScript and in Telerik UI Controls for NativeScript.

    Regards,
    Nikolay Iliev
    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