Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Polymer custom element containing table cells?

I am trying to create a custom element with Polymer that contains a few table cells. I want to include it in a table row. The problem I am having is that the custom element tags break the format of the table (because the table row expects to contain table cell elements directly rather than via a sub-element).

Is there some way of doing what I want?

like image 455
Chris Avatar asked Apr 02 '26 09:04

Chris


1 Answers

I solved this issue by simply removing the <tr> from the equation.

<table>
  <thead>
    <th>Name</th>
    <th>Date</th>
  </thead>
  <tbody>
    <template is="dom-repeat" items="[[items]]">
      <custom-component item="{{item}}"></custom-component>
    </template>
  </tbody>
</table>

The custom component's template looks like this:

<template>
  <td>{{item.name}}</td>
  <td>{{item.date}}</td>
</template>

And then I added styling for the custom-component in the component using it, saying:

custom-component {
  display: table-row;
}
like image 85
Soesah Avatar answered Apr 03 '26 22:04

Soesah



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!