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

Array of Objects

2 Answers 70 Views
General Discussion
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Christopher
Top achievements
Rank 1
Christopher asked on 15 Aug 2017, 11:59 AM

In the backend console, there seems to be no way to add an array of objects using the interface. You can add an array of text, numbers, etc. but not an empty array or an array of objects. We want to designate some fields as being an array ready to accept objects.

We are not storing relations in the array - we need to store multiple row values for a record in one-to-many grids like this:

Content Type: Properties
hasMoved: true;  //this is a regular field storing one-to-one value 
APN: [{Seq: 500, value: ‘Hello’}, {Seq: 600, value: ‘Goodbye’}]  //this is a grid field storing more than one grid value entry for this record

We just want to create a field for APN that is an array that will ultimately hold objects.

What are we doing wrong?

Thanks.

2 Answers, 1 is accepted

Sort by
0
Anton Dobrev
Telerik team
answered on 16 Aug 2017, 02:16 PM
Hi,

In the Structure of your Properties content type you can define the APN field as an Object and you will get the option to use a complex object creator and visualizer for this field in the create/detail view of an entity. 

Please note that doing so will have an UI-only effect, in the database you will be able to store any supported type and value to this field. Put simply, you only need to send the value of the field in the payload to the server and it will be written to the database, independent of the type you declared in the Structure. You can read more about this here

For some fields like GeoPoint you still need to define them in the structure though. Same for setting a field value constraint as unique. 

I hope this answers your question. 
   
Regards,
Anton Dobrev
Progress Telerik
 
Everlive is now Telerik Backend Services, and is part of the Telerik Platform.
 
0
Christopher
Top achievements
Rank 1
answered on 16 Aug 2017, 02:24 PM

Thanks Anton. I understand.

Also, in this case, we created a separate content type for each grid to store the value for each grid row set of items. This looks like it is better suited for that function.

Thanks again.

Tags
General Discussion
Asked by
Christopher
Top achievements
Rank 1
Answers by
Anton Dobrev
Telerik team
Christopher
Top achievements
Rank 1
Share this question
or