Adding XML Dynamically In A View

I’ve been trying to figure out a way to render columns and object tables dynamically in an XML view, but haven’t been able to figure out a way to do so. I’m filtering through an array of objects, and each object belong to a specific category. I need to be able to render a table for each category and attach those objects to the table it belongs to. The reason I need to render into the xml dynamically is because I’m pulling this data through an api that constantly updates with new categories and/or objects.
The only thing I can do in the XML that’s relatively similar to what I’m trying to achieve is call a function where text can be rendered:

<info>{$:renderText()}</info>

Any help would be much appreciated!
Thank you in advance!

@jmvanhorn

It is not currently possible to dynamically render XML, ie “add” or “remove” XML, at run time, except for the sidebar and nav components whose content can be generated from JS.

So your specific options are to

  1. Hardcode a set amount of object-table components and columns and then dynamically showing / hiding them based on the content of the data that is returned from the API up to the preset max amount of tables / columns. For example you can add 10 object-tables to your view, 1 for each potential object type that could be returned via the API, but then only showing those that actually have data returned from the API. And you can do a similar thing with columns. Define the object-table with 20 columns, but only show the columns that are necessary based on the content of the data
  2. Split your workflow in multiple steps which would negate (theoretically at least) the necessity of having dynamic tables and columns.

I hope this helps.

Please add the suggestion of being able to dynamically change your View XML to our public roadmap for future consideration

1 Like