Note that there are some explanatory texts on larger screens.

plurals
  1. POSuggestions of outputting JSON as a table - jQuery.tmpl? Something else?
    primarykey
    data
    text
    <p>I've got JSON being returned from the server. I'll paste the 2 first records here (long), but in theory it could be 100's.</p> <pre><code>{ "1": { "text": "First Thoughts and Feelings", "filters": { "2": { "text": "% Postive", "banners": { "2": { "text": "Ontario", "val": "46.1907" }, "3": { "text": "Quebec", "val": "47.9016" }, "1": { "text": "Total Respondents", "val": "52.9057" } } }, "1": { "text": "Net Positive", "banners": { "2": { "text": "Ontario", "val": "51.9106" }, "3": { "text": "Quebec", "val": "50.7760" }, "1": { "text": "Total Respondents", "val": "47.9157" } } } } }, "2": { "text": "Purchase Intent", "filters": { "2": { "text": "% Postive", "banners": { "2": { "text": "Ontario", "val": "54.5407" }, "3": { "text": "Quebec", "val": "53.9017" }, "1": { "text": "Total Respondents", "val": "49.7267" } } }, "1": { "text": "Net Positive", "banners": { "2": { "text": "Ontario", "val": "51.7294" }, "3": { "text": "Quebec", "val": "52.7261" }, "1": { "text": "Total Respondents", "val": "52.9762" } } } } } } </code></pre> <p>I want to put this data into a table, where there is basically a column for question (the root text), the filter, and then each banner. I'd create a thead like this</p> <pre><code>&lt;thead&gt; &lt;tr&gt; &lt;th&gt;Question&lt;/th&gt; &lt;th&gt;Filter&lt;/th&gt; &lt;th&gt;Ontario&lt;/th&gt; &lt;th&gt;Quebec&lt;/th&gt; &lt;th&gt;Total&lt;/th&gt; &lt;/tr&gt;... </code></pre> <p>I'm trying to figure out the best way to populate this table given that the number of banners is dynamic, could be 2, could be 20.</p> <p>If there are 2 questions, 2 filters, with 3 banners each, I need a table consisting of 5 columns, 4 rows (excluding headers). </p> <pre><code>Row 1 -&gt; Q1 -&gt; filter1 -&gt; banner1 -&gt; banner2 -&gt; banner3 Row 2 -&gt; Q1 -&gt; filter2 -&gt; banner1 -&gt; banner2 -&gt; banner3 Row 3 -&gt; Q2 -&gt; filter1 -&gt; banner1 -&gt; banner2 -&gt; banner3 Row 4 -&gt; Q2 -&gt; filter2 -&gt; banner1 -&gt; banner2 -&gt; banner3 </code></pre> <p>Ideally sortable too I guess, but any column, though I know I can add that type of functionality with jQueury afterwards.</p> <p>Looking for suggestions on how to get this done as I'm having trouble wrapping my head around it.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload