Saulis / iron-data-table

iron-data-table is a Web Component for displaying data as a table or grid. Built on top of iron-list using Polymer.
Apache License 2.0
147 stars 65 forks source link

support set column object and retrive column index #155

Open andrewillard opened 8 years ago

andrewillard commented 8 years ago

I created this PR to make avaialable columnIndex binding beforeCellBind and support set column item when is creating a dynamic column, like:

  <iron-data-table id="table" items="{{items}}">
    <data-table-column name="Fixed Column">
      <template>
        <foo></foo>
       </template>
    </data-table-column>
    <template is="dom-repeat" items="{{dynamicColumns}}" as="columnItem">
      <data-table-column column-item="{{columnItem}}">
        <template is="header">
          <bar></bar>
        </template>
        <template>
          <foo></foo>
        </template>
      </data-table-column>
    </template>
  </iron-data-table>

This change is Reviewable

gabrielle-perez-movile commented 8 years ago

Ow, this is the solution I was looking for...

notnotgabriel commented 8 years ago

Thanks to perform this solution bro.

Saulis commented 8 years ago

Hi there! Sorry for the delay!

The columnIndex looks like a nice addition, thanks!

However, I'm not sure if the columnItem is needed – since all the column properties are available inside beforeCellBind(data, cell) by using data.column.foo right? Or am I missing something?

andrewillard commented 8 years ago

Hi Saulis, no problem, thanks for your attention!

I suggested columnItem because today we only have row item available to use two way data bind, there aren't a collection items for columns as we have for rows, because we always have created static columns until now. :) I don't know if is possible solve this using beforeCellBind, do you know?

For dynamic columns we need to set what column item we want to use in two way data bind for each data-table-column. If it isn't look good, what do you think about create a new element like data-table-columns with items property, so we can do a dom-repeat inside the element instead do it outside?

Thanks again.

Saulis commented 8 years ago

@andrew-silva-movile hmm not sure if I'm missing something.. can you post some example code for the use case?

The reason why I'm a bit confused is that in the PR the only change that columnItem property makes is that it will be available through cell.columnItem inside beforeCellBind(data, cell) right? However, you can already access the same property today by using data.column.columnItem without adding any new bindings?