<vaadin-grid id="grid" items="[[data]]" active-item="{{activeItem}}">
<vaadin-grid-column>
<template class="header">#</template>
<template>[[index]]</template>
</vaadin-grid-column>
<vaadin-grid-column>
<template class="header">First Name</template>
<template>[[item.name.first]]</template>
</vaadin-grid-column>
</vaadin-grid>使用activeItem pattern vaadin-grid可以在单击行时选择行数据。
有没有办法通过一个按钮动作来调用它呢?
也许是通过从父节点中选择一个属性?
<vaadin-grid id="grid" items="[[data]]" active-item="{{activeItem}}">
<vaadin-grid-column>
<template class="header">#</template>
<template>[[index]]</template>
</vaadin-grid-column>
<vaadin-grid-column>
<template class="header">First Name</template>
<template><paper-button on-tap="selectRowData">Select</paper-button</template>
</vaadin-grid-column>
</vaadin-grid>发布于 2018-06-04 23:37:46
通过获取行索引并从数据源中选择行,可以使用按钮选择行数据。
<vaadin-grid id="grid" items="[[data]]" active-item="{{activeItem}}">
<vaadin-grid-column>
<template class="header">#</template>
<template>[[index]]</template>
</vaadin-grid-column>
<vaadin-grid-column>
<template class="header">First Name</template>
<template>
<paper-button id="[[index]] on-tap="selectRowData">Select</paper-button</template>
</vaadin-grid-column>
</vaadin-grid>..。
selectRowData(e) {
let row = this.data[e.detail.sourceEvent.target.id];
// do something with row data
}发布于 2018-06-04 22:15:34
在其中一个单元格模板中放置一个按钮,为接收该项作为参数的绑定单击侦听器。使用聚合物数据绑定最容易做到这一点。然后在监听器回调中将该项添加到grid.selectedItems数组中。
发布于 2018-06-14 21:50:23
<vaadin-grid-column width="14em">
<template>
<vaadin-button on-click="deleteUser" >
<iron-icon icon="icons:delete" ></iron-icon>
</vaadin-button>
</template>
//您不需要定义任何模型,它是简单可用的
deleteUser(e)
{
let row=e.model.item;
console.log(row);
// e.g. make a REST Delete Operation with iron-ajax
this.$.ajaxUserModify.url=this.dataURL+"/"+row.id;
this.$.ajaxUserModify.method="delete";
this.$.ajaxUserModify.body="";
this.$.ajaxUserModify.generateRequest();
}https://stackoverflow.com/questions/50682036
复制相似问题