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

Dynamic Fields

10 Answers 87 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.
Ryan
Top achievements
Rank 1
Ryan asked on 14 Jun 2016, 10:47 PM
Does DataForm support adding dynamic fields that won't be known until runtime? I can't statically put them as properties for an object and pass that for the datasource initialization because I have fields that will only be known during runtime.

10 Answers, 1 is accepted

Sort by
0
Sophi
Telerik team
answered on 17 Jun 2016, 06:48 AM
Hello Ryan,

Does your scenario include loading remote data or loading data from files? Could you, please, give us more details about what you are aiming to achieve with the TKDataForm, this way we can assist you and provide you with proper solution in short terms.

Looking forward to hearing from you.

Regards,
Sophi
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Ryan
Top achievements
Rank 1
answered on 17 Jun 2016, 06:06 PM
I am loading remote data. I will not know what the field names are until runtime because the fields are dynamically created by somebody else. What I want to do is load all of these fields and add them to the dataform. Currently I have a static section where I will know all of the fields statically before runtime and so I am passing in an object to my DataSource so that DataForm can present these fields in which I statically know the field names before runtime. However I also have a dynamic fields section that I will not know until runtime. I need to add these dynamic fields to the data form.
0
Ryan
Top achievements
Rank 1
answered on 17 Jun 2016, 11:44 PM
These dynamic fields will come back from my web service as a dictionary with keys and values. The key is the field name and the value is what to display. How can I add this to the dataform?
0
Sophi
Telerik team
answered on 21 Jun 2016, 07:50 AM
Hello Ryan,

TKDataForm allows you to change the sourceObject any time and just call the reloadData method of the TKDataForm. You can change the sourceObject at runtime with the updated one, or even create a new instance of the TKDataFormEntityDataSource with a sourceObject out of JSON input.

You can refer to this example for the JSON support feature.

Regards,
Sophi
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Ryan
Top achievements
Rank 1
answered on 08 Aug 2016, 06:07 PM
Currently I am mapping a certain key path of my JSON to a source object but what I do is map the dynamic portion of my JSON (another keypath) to an NSDictionary. Is there a way for me to map one group of the data form to a source object and another group of the data form to JSON at a certain keypath (my dynamic portion of the JSON)?
0
Sophi
Telerik team
answered on 10 Aug 2016, 07:37 AM
Hi Ryan,

Currently the TKDataForm can be loaded only from a single source object or JSON. You cannot have different groups loaded from separate sources.
When you get the remote data you should create a source object or feed directly the TKDataForm with NSDictionary or JSON file and then reload it by calling the reloadData method.

Regards,
Sophi
Telerik by Progress
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Jesús
Top achievements
Rank 1
answered on 30 Mar 2017, 12:39 AM

Hello Sophi, do you have an example of how to create the source object? The example that you mencioned before is based on a JSON struct. But i want to add properties to my current BO or create a new BO with more properties recived dinamically. I think that is using the TKEntity Class, but i don't have any idea about how this works.

Greetings and thanks.

0
Todor
Telerik team
answered on 03 Apr 2017, 10:23 AM
Hi Jesús,

Here's an example that populates the data form without json. When you need to update the data form with another object with different properties, you just need to create a new data source from the new object and then assign it to the data form. 

Let us know if you need further assistance.

Regards,
Todor
Telerik by Progress
Want to build beautiful Android apps as well? Check out UI for Android which enables the same set of scenarios, allowing you to create the same great app experience on both iOS and Android.
0
Jesús
Top achievements
Rank 1
answered on 04 Apr 2017, 04:25 PM

Hello Todor.

For my understanding, this example that you are sharing me, has an BO defined previously. And the  thing is, that i want to add properties defined on the fly to my existent BO. For example, if i have a catalog with one or many sub levels, i want to create that sub levels on my form. I don't know the number of levels, until my method returns from server. So if i define a BO previously, how can i add properties that don't exist on it?

thanks a lot for your help and pacient.

0
Todor
Telerik team
answered on 06 Apr 2017, 08:17 AM
Hi Jesús,

Thank you for writing back.

The DataForm is always related to a single business object and there is no option to have an editor in the data form that is not related to a property from your business object. The options that you have to populate a data form are:
 1) through an instance of a class that represents your business object
 2) through json string

If your business object needs to be updated runtime, you still need to use one of the above mentioned approaches. Here's what to do for each of them:
 1) you can create the new class at runtime as demonstrated here and pass an instance of it to the data form
 2) you can create a json from the information that you have and pass the json to the data form  

I hope this information helps.

Regards,
Todor
Telerik by Progress
Want to build beautiful Android apps as well? Check out UI for Android which enables the same set of scenarios, allowing you to create the same great app experience on both iOS and Android.
Tags
DataForm
Asked by
Ryan
Top achievements
Rank 1
Answers by
Sophi
Telerik team
Ryan
Top achievements
Rank 1
Jesús
Top achievements
Rank 1
Todor
Telerik team
Share this question
or