RyanShay
Posts: 0
Joined: Mon Mar 12, 2012 2:29 am

Dynamic Fields based on Array?

Is it possible to create elements dynamically, from an array returned from a service call?

For example: Given the following array, I want to create two sections with an undetermined number of grid rows.

[
{
"fields": [
{
"field_name": "Sample Field",
"field_value": "123456"
},
{
"field_name": "Sample Field 2",
"field_value": "123"
}
],
"section_name": "Section As"
},
{
"fields": [
{
"field_name": "Sample Field",
"field_value": "123456"
},
{
"field_name": "Sample Field 2",
"field_value": "123"
}
],
"section_name": "Section B"
}
]

I've added a single collapsible section to the page, inside the section content is a grid with a single row and two columns. (grid is used for formatting). Inside the first grid cell is a label to hold the field_name, and inside the second grid cell is a label to hold the field_value. This would ideally create 2 collapsible blocks, with two rows in each.

This may not be possible with the current Builder Interface, but wanted to check as it would reduce development time significantly on my end. I tried mapping the output to each element but could not seem to get this to work.

Thanks!

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

Dynamic Fields based on Array?

Can you build a static sample page to show us how it would look?

RyanShay
Posts: 0
Joined: Mon Mar 12, 2012 2:29 am

Dynamic Fields based on Array?

Max, thanks for the prompt response.

I've made the page I was trying to get this to work on public to hopefully give you a better idea of what I'm talking about.

http://tiggzi.com/preview/29264/

Also, think I found a bug. When "collapsed" is unchecked on the block properties, it still defaults to being closed. Not a huge deal, but just a heads up.

So, basically, the reason behind wanting to do this, is that if requirements should change and I need to add an additional field of info or a completely new section, I'd like to avoid having to rebuild & redeploy the application.

Thanks!

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

Dynamic Fields based on Array?

So the table is inside the collapsible block?

RyanShay
Posts: 0
Joined: Mon Mar 12, 2012 2:29 am

Dynamic Fields based on Array?

Also, just as a side note.

I'm basically just trying to replicate a table with collapsible sections. So this could probably be accomplished by building the necessary html for the table via javascript and inserting it into a custom html block which I think I saw that you said was planned and being worked on. I'm just trying to see if it's currently possible in the builder.

RyanShay
Posts: 0
Joined: Mon Mar 12, 2012 2:29 am

Dynamic Fields based on Array?

Correct. I'm trying to basically have a section (collapsible block) of details that can be rolled up and out of the way if they're not needed. I guess this really isn't a requirement so to speak if it's going to cause more issues than it's worth. I could just forgo the block and use a grid as long as I can add rows to that based on the number of array elements returned from the service call.

RyanShay
Posts: 0
Joined: Mon Mar 12, 2012 2:29 am

Dynamic Fields based on Array?

The reason for the block was that I was hoping to be able to create additional blocks on the fly as well. With an undetermined number of table "rows" inside.

RyanShay
Posts: 0
Joined: Mon Mar 12, 2012 2:29 am

Dynamic Fields based on Array?

Not sure if you updated something on your end or if I just did something differently, but this seems to work now. So this ticket can be closed as resolved.

Thanks again for responding so quickly!

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

Dynamic Fields based on Array?

[quote:]
Also, think I found a bug. When "collapsed" is unchecked on the block properties, it still defaults to being closed. Not a huge deal, but just a heads up.
[/quote]
Can you try this again? I wasn't able to reproduce this problem.

Return to “Issues”