Dynamic Fields

Thread is closed for posting
11 posts, 0 answers
  1. Ryan
    Ryan avatar
    37 posts
    Member since:
    Jun 2016

    Posted 14 Jun 2016 Link to this post

    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.
  2. Sophi
    Admin
    Sophi avatar
    103 posts

    Posted 17 Jun 2016 Link to this post

    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
  3. Ryan
    Ryan avatar
    37 posts
    Member since:
    Jun 2016

    Posted 17 Jun 2016 in reply to Sophi Link to this post

    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.
  4. Ryan
    Ryan avatar
    37 posts
    Member since:
    Jun 2016

    Posted 17 Jun 2016 in reply to Ryan Link to this post

    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?
  5. Sophi
    Admin
    Sophi avatar
    103 posts

    Posted 21 Jun 2016 Link to this post

    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
  6. Ryan
    Ryan avatar
    37 posts
    Member since:
    Jun 2016

    Posted 08 Aug 2016 in reply to Sophi Link to this post

    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)?
  7. Sophi
    Admin
    Sophi avatar
    103 posts

    Posted 10 Aug 2016 Link to this post

    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
  8. Jesús
    Jesús avatar
    7 posts
    Member since:
    Feb 2013

    Posted 29 Mar in reply to Sophi Link to this post

    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.

  9. Todor
    Admin
    Todor avatar
    798 posts

    Posted 03 Apr Link to this post

    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.
  10. Jesús
    Jesús avatar
    7 posts
    Member since:
    Feb 2013

    Posted 04 Apr in reply to Todor Link to this post

    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.

  11. Todor
    Admin
    Todor avatar
    798 posts

    Posted 06 Apr Link to this post

    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.
Back to Top