行選擇是不是爲我工作。 selectedItems數組僅在我一次選擇所有內容時纔會更改。我不確定是否有錯誤或者是否有錯誤。vaadin網選擇不工作
selectedItems:包含所選項目的數組。 https://www.webcomponents.org/element/vaadin/vaadin-grid/elements/vaadin-grid
<link rel="import" href="../bower_components/polymer/polymer-element.html">
<link rel="import" href="../bower_components/vaadin-grid/vaadin-grid.html">
<link rel="import" href="../bower_components/vaadin-grid/vaadin-grid-selection-column.html">
<dom-module id="schedule-vaadin-test">
<template>
<vaadin-grid id="material" aria-label="Array Data Example" items="[[items]]" selected-items="{{selectedItems}}">
<vaadin-grid-selection-column auto-select>
</vaadin-grid-selection-column>
<vaadin-grid-column width="50px" flex-grow="0">
<template class="header">#</template>
<template>[[index]]</template>
</vaadin-grid-column>
<vaadin-grid-column>
<template class="header">First Name</template>
<template>[[item.firstName]]</template>
</vaadin-grid-column>
<vaadin-grid-column>
<template class="header">Last Name</template>
<template>[[item.lastName]]</template>
</vaadin-grid-column>
</vaadin-grid>
</template>
<script>
/**
* @customElement
* @polymer
*/
class ScheduleVaadinTest extends Polymer.Element {
static get is() {
return 'schedule-vaadin-test';
}
static get properties() {
return {
items: {
type: Array,
value: [{"firstName":"Foo", "lastName":"Bar"},
{"firstName":"Foo", "lastName":"Bar"},
{"firstName":"Foo", "lastName":"Bar"}]
},
selectedItems: {
type: Array,
observer: 'selectedItemsChanged'
}
};
}
static get observers() {
return []
}
selectedItemsChanged() {
console.log(this.selectedItems);
}
}
customElements.define(ScheduleVaadinTest.is, ScheduleVaadinTest);
</script>
</dom-module>
當單擊一行時,該行中的項目對象被分配給activeItem。只要啓用自動選擇功能並且用戶單擊該行以選擇它,您的解決方案就會工作。使用複選框不起作用,因爲activeItem不會更改。如果您使用複選框選擇一個項目,而使用該行的另一個項目,selectedItems數組仍然正確。 –