如何获取vaadin-grid的行索引

How to get Row Index of vaadin-grid

我正在尝试遍历 vaadin-grid 行来设置行样式,但是 select 遇到问题。

<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
}

我可以 select 行数据 this.$.grid.items[arrayIndex]...

如何select一行设置行样式?

根据 Gilberto 的建议:

<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'
}