如何使用按钮获取`vaadin-grid`行数据

时间:2018-06-02 18:52:51

标签: select model vaadin vaadin-grid

<vaadin-grid items="[[data]]" width="100%" hidden$="[[loading]]" id="grid" active-item="{{activeItem}}">
  <vaadin-grid-column width="36pt" flex-grow="0">
    <template class="header">
      <h3>#</h3>
    </template>
    <template>
      <p class="center">[[i(index)]]</p>
    </template>
  </vaadin-grid-column>
</vaadin-grid>

使用vaadin-grid上的有效项属性,您可以在单击该行时选择行中包含的数据模型。

有没有办法用按钮进行相同的选择?

<vaadin-grid items="[[data]]" width="100%" hidden$="[[loading]]" id="grid" active-item="{{activeItem}}">
  <vaadin-grid-column width="36pt" flex-grow="0" id="child">
    <template class="header" id="col">
      <h3>#</h3>
    </template>
    <template>
      <paper-button on-tap="getRowData>Get</paper-button>
    </template>
  </vaadin-grid-column>
</vaadin-grid>

...

getRowData() {
  // do something
}

我无法找到合适的选择器。我试过了:

this.$.child.parentElement.activeItem;
this.$.child.parentElement.selectedItems;
this.$.col.select();

0 个答案:

没有答案