Coder Social home page Coder Social logo

How to do a Dynamic table about iron-data-table HOT 4 CLOSED

saulis avatar saulis commented on August 23, 2024
How to do a Dynamic table

from iron-data-table.

Comments (4)

Saulis avatar Saulis commented on August 23, 2024 2

Hi!

Not sure what you mean by "linking" the item and column together, but you should be able to bind the column from dom-repeat normally anywhere you like.

So in practice:

<data-table-column name="[[column.label]]">
  <template>[[column.label]]</template>
</data-table-column>

But.. looking at your example I would guess that you're trying to access a property on the item with a name of the column.label right?

For that, I'd suggest having a function in the parent component which takes both item and column.label as parameters.

_itemValue: function(item, prop) {
  return item[prop];
}
<data-table-column name="[[column.label]]">
  <template>[[_itemValue(item, column.label)]]</template>
</data-table-column>

from iron-data-table.

Stefdv avatar Stefdv commented on August 23, 2024

Tx for the reply.
Yes, that is what i mean...and the solution is so obvious ;)
tx again ( also for iron-datatable)

from iron-data-table.

Saulis avatar Saulis commented on August 23, 2024

np!

from iron-data-table.

Stefdv avatar Stefdv commented on August 23, 2024

Sorry...haven't had time to actually try it out...

  <iron-data-table items="[[records]]">
        <template is="dom-repeat" items="[[origin.fields]]" as="column">
          <data-table-column name="[[column.label]]">
           <template>[[_itemValue(item,column.label)]]</template>

          </data-table-column>
        </template>
    </iron-data-table>
  _itemValue: function(record,prop) {
        console.log(record,prop)
        return record[prop]
      },

now it seems that in <template>[[_itemValue(item,column.label)]]</template> column.label is not accesible anymore. If i only send 'item' to the _itemValue function it logs the item. If i only send column (or column.label) it doesn't do anything.
Note: The columns-names are rendered

A few hours later...
Nope: column is not available anymore inside the <data-table-column>

from iron-data-table.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.