This is a migrated thread and some comments may be shown as answers.

DataForm with nested object

3 Answers 168 Views
DataForm
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Vamsi
Top achievements
Rank 1
Vamsi asked on 15 May 2017, 06:36 AM

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

3 Answers, 1 is accepted

Sort by
0
Nick Iliev
Telerik team
answered on 15 May 2017, 10:36 AM
Hello ,

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.
0
Vamsi
Top achievements
Rank 1
answered on 15 May 2017, 02:15 PM

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

0
Nick Iliev
Telerik team
answered on 16 May 2017, 05:38 AM
Hey ,

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.
Tags
DataForm
Asked by
Vamsi
Top achievements
Rank 1
Answers by
Nick Iliev
Telerik team
Vamsi
Top achievements
Rank 1
Share this question
or