I’m trying to setup a table that is dynamic with its column headers and column values.
Currently I have the first column value (name), but I don’t want to hard code each potential column/fields. Is there a way to create a loop/repeat that displays all of them?
For example, let’s say I have these columns/fields: Name, Email, Phone, and Address.
Is there a way to display the values from all of those columns/fields? Similar to how the repeat gets all records without having to hardcode each row? But instead of rows, it’s the values that will show in one row.
You can use the Bootstrap table generator to generate all of the columns but that wouldn’t be dynamic, you would need to re-run the generator when fields changed
You mean like this?
<div class="container">
<div class="row" is="dmx-repeat" id="each_stripe_product" dmx-bind:repeat="fetch_products.data.products">
<dmx-value id="current_repeat_row" dmx-bind:value="$value"></dmx-value>
<div class="col" dmx-text="'Product ID: '+product_id"></div>
<div class="col" dmx-repeat:repeat_each_key="current_repeat_row.value.keys()" dmx-text="current_repeat_row.value[$value]">
</div>
</div>
</div>
The row is a repeat of an array (in this example, stripe products)
Inside it has a variable that stores the values of the entire current row.
There is then a column that displays the product id (in the traditional manner).
And then a column that repeats for each of the keys of the original repeat and displays the value of each key.
2 Likes
Thanks @mebeingken! That gives me a direction.
1 Like