Как получить индекс строки vaadin-grid - PullRequest
0 голосов
/ 26 июня 2018

Я пытаюсь перебрать строки vaadin-grid для установки стилей, но у меня проблемы с выбором строки.

<vaadin-grid id="grid" items="[[data]]">
  <vaadin-grid-column>
    <template class="header">
      <vaadin-grid-sorter path="noLine">
        <h1>Line No.</h1>
      </vaadin-grid-sorter>
    </template>
    <template>
      <p>[[item.noLine]]</p>
    </template>
</vaadin-grid-column>

...

_selectRow() {
  // Programmatically select row
}

Я могу выбрать данные строки с помощью this.$.grid.items[arrayIndex] ...

Как выбрать строку для установки стиля строки?

1 Ответ

0 голосов
/ 10 июля 2018

За предложение Гилберто:

<vaadin-grid-column>
   <template class="header">
     <vaadin-grid-sorter path="qty">
       <h3>Qty</h3>
       </vaadin-grid-sorter>
    </template>
  <template>
    <p style$="color: [[setCellStyle(item.qty item.qtyOther]]</p>
  </template>
</vaadin-grid-column>

...

setCellStyle(qty, qtyOther) {
  if(qty <= qtyOrder) return 'black'
  else return 'orangered'
}
...