iron-data-table icon indicating copy to clipboard operation
iron-data-table copied to clipboard

support set column object and retrive column index

Open andrewillard opened this issue 9 years ago • 5 comments

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

andrewillard avatar Oct 10 '16 13:10 andrewillard

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

gabrielle-perez-movile avatar Oct 10 '16 18:10 gabrielle-perez-movile

Thanks to perform this solution bro.

notnotgabriel avatar Oct 10 '16 18:10 notnotgabriel

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?

Saulis avatar Oct 21 '16 09:10 Saulis

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.

andrewillard avatar Oct 27 '16 03:10 andrewillard

@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?

Saulis avatar Oct 27 '16 08:10 Saulis