Note that there are some explanatory texts on larger screens.

plurals
  1. POBind table with dynamic rows and columns from two lists
    primarykey
    data
    text
    <p>I'm trying to create a family-calendar style app that has a table with names of persons as columns and dates as rows. Not sure how to do this but this is what I have so far:</p> <p><strong>calendartable.html</strong></p> <pre class="lang-html prettyprint-override"><code>&lt;polymer-element name="calendar-table"&gt; &lt;template&gt; &lt;table&gt; &lt;tr template repeat="{{dates}}"&gt; &lt;td template repeat="{{people}}"&gt;{{name}}&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/template&gt; &lt;script type="application/dart" src="calendartable.dart"&gt;&lt;/script&gt; &lt;/polymer-element&gt; </code></pre> <p><strong>calendartable.dart</strong></p> <pre class="lang-dart prettyprint-override"><code>import 'package:polymer/polymer.dart'; class Person { String name; Person(this.name); } @CustomTag('calendar-table') class CalendarTable extends PolymerElement { List people = [new Person("Kalle"), new Person("Olle")]; List dates = [new DateTime(2013, 09, 09), new DateTime(2013, 09, 10)]; } </code></pre> <p>Some questions about the above:</p> <ol> <li>The above code does not work, "Uncaught Error: EvalException: variable not found: people in 193757919". Is this due to <a href="https://code.google.com/p/dart/issues/detail?id=12742" rel="nofollow">this bug</a> or am I doing something else wrong?</li> <li>Is there another way to create tables with both dynamic rows and columns? Maybe some workaround if the bug is affecting my code?</li> <li>Is there any docs about using "template" as an attribute rather than an element? (Just saw some other code that used it as an attribute and it seems to work but cannot find any official docs)</li> </ol> <p><strong>UPDATE:</strong></p> <p>The output I am looking for is something like this. (I plan to add content for the "X" in the cells once I have the basic layout rendering correctly):</p> <pre><code>+------------+-------+------+ | | Kalle | Olle | +------------+-------|------+ | 2013-09-09 | X | X | +------------+-------+------+ | 2013-09-10 | X | X | +------------+-------+------+ </code></pre> <p><strong>UPDATE:</strong></p> <p>This is what I ended up with that works (thanks to ianmjones for pointing me in the right direction!):</p> <p><strong>calendartable.html</strong></p> <pre class="lang-html prettyprint-override"><code>&lt;polymer-element name="calendar-table"&gt; &lt;template&gt; &lt;table&gt; &lt;tr&gt; &lt;td&gt;&lt;/td&gt; &lt;template repeat="{{person in people}}"&gt; &lt;td&gt;{{person.name}}&lt;/td&gt; &lt;/template&gt; &lt;/tr&gt; &lt;template repeat="{{date in dates}}"&gt; &lt;tr&gt; &lt;td&gt;{{date.toString()}}&lt;/td&gt; &lt;template repeat="{{person in people}}"&gt; &lt;td&gt;X&lt;/td&gt; &lt;/template&gt; &lt;/tr&gt; &lt;/template&gt; &lt;/table&gt; &lt;/template&gt; &lt;script type="application/dart" src="calendartable.dart"&gt;&lt;/script&gt; &lt;/polymer-element&gt; </code></pre>
    singulars
    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.
    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