Selection demo
parent
e9bfcecf73
commit
4ed4931915
|
@ -11,11 +11,11 @@
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<h5>Single</h5>
|
<h5>Single</h5>
|
||||||
<p>In single mode, a row is selected on click event of a row. If the row is already selected then the row gets unselected.</p>
|
<p>In single mode, a row is selected on click event of a row. If the row is already selected then the row gets unselected.</p>
|
||||||
<DataTable :value="cars" :selection.sync="selectedCar1" selectionMode="single" dataKey="vin">
|
<DataTable :value="products" :selection.sync="selectedProduct1" selectionMode="single" dataKey="id">
|
||||||
<Column field="vin" header="Vin"></Column>
|
<Column field="code" header="Code"></Column>
|
||||||
<Column field="year" header="Year"></Column>
|
<Column field="name" header="Name"></Column>
|
||||||
<Column field="brand" header="Brand"></Column>
|
<Column field="category" header="Category"></Column>
|
||||||
<Column field="color" header="Color"></Column>
|
<Column field="quantity" header="Quantity"></Column>
|
||||||
</DataTable>
|
</DataTable>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -23,60 +23,60 @@
|
||||||
<h5>Multiple</h5>
|
<h5>Multiple</h5>
|
||||||
<p>In multiple mode, selection binding should be an array. For touch enabled devices, selection is managed by tapping and for other devices metakey or shiftkey are required.
|
<p>In multiple mode, selection binding should be an array. For touch enabled devices, selection is managed by tapping and for other devices metakey or shiftkey are required.
|
||||||
Setting metaKeySelection property as false enables multiple selection without meta key.</p>
|
Setting metaKeySelection property as false enables multiple selection without meta key.</p>
|
||||||
<DataTable :value="cars" :selection.sync="selectedCars1" selectionMode="multiple" dataKey="vin">
|
<DataTable :value="products" :selection.sync="selectedProducts1" selectionMode="multiple" dataKey="id">
|
||||||
<template #header>
|
<template #header>
|
||||||
Multiple Selection with MetaKey
|
Multiple Selection with MetaKey
|
||||||
</template>
|
</template>
|
||||||
<Column field="vin" header="Vin"></Column>
|
<Column field="code" header="Code"></Column>
|
||||||
<Column field="year" header="Year"></Column>
|
<Column field="name" header="Name"></Column>
|
||||||
<Column field="brand" header="Brand"></Column>
|
<Column field="category" header="Category"></Column>
|
||||||
<Column field="color" header="Color"></Column>
|
<Column field="quantity" header="Quantity"></Column>
|
||||||
</DataTable>
|
</DataTable>
|
||||||
|
|
||||||
<DataTable :value="cars" :selection.sync="selectedCars2" selectionMode="multiple" dataKey="vin" :metaKeySelection="false" style="margin-top: 2em">
|
<DataTable :value="products" :selection.sync="selectedProducts2" selectionMode="multiple" dataKey="id" :metaKeySelection="false" style="margin-top: 2em">
|
||||||
<template #header>
|
<template #header>
|
||||||
Multiple Selection without MetaKey
|
Multiple Selection without MetaKey
|
||||||
</template>
|
</template>
|
||||||
<Column field="vin" header="Vin"></Column>
|
<Column field="code" header="Code"></Column>
|
||||||
<Column field="year" header="Year"></Column>
|
<Column field="name" header="Name"></Column>
|
||||||
<Column field="brand" header="Brand"></Column>
|
<Column field="category" header="Category"></Column>
|
||||||
<Column field="color" header="Color"></Column>
|
<Column field="quantity" header="Quantity"></Column>
|
||||||
</DataTable>
|
</DataTable>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<h5>Events</h5>
|
<h5>Events</h5>
|
||||||
<p>row-select and row-unselects are available as selection events.</p>
|
<p>row-select and row-unselects are available as selection events.</p>
|
||||||
<DataTable :value="cars" :selection.sync="selectedCar2" selectionMode="single" dataKey="vin"
|
<DataTable :value="products" :selection.sync="selectedProduct2" selectionMode="single" dataKey="id"
|
||||||
@row-select="onRowSelect" @row-unselect="onRowUnselect">
|
@row-select="onRowSelect" @row-unselect="onRowUnselect">
|
||||||
<Column field="vin" header="Vin"></Column>
|
<Column field="code" header="Code"></Column>
|
||||||
<Column field="year" header="Year"></Column>
|
<Column field="name" header="Name"></Column>
|
||||||
<Column field="brand" header="Brand"></Column>
|
<Column field="category" header="Category"></Column>
|
||||||
<Column field="color" header="Color"></Column>
|
<Column field="quantity" header="Quantity"></Column>
|
||||||
</DataTable>
|
</DataTable>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<h5>RadioButton</h5>
|
<h5>RadioButton</h5>
|
||||||
<p>Single selection can also be handled using radio buttons by enabling the selectionMode property of column as "single".</p>
|
<p>Single selection can also be handled using radio buttons by enabling the selectionMode property of column as "single".</p>
|
||||||
<DataTable :value="cars" :selection.sync="selectedCar3" dataKey="vin">
|
<DataTable :value="products" :selection.sync="selectedProduct3" dataKey="id">
|
||||||
<Column selectionMode="single" headerStyle="width: 3em"></Column>
|
<Column selectionMode="single" headerStyle="width: 3em"></Column>
|
||||||
<Column field="vin" header="Vin"></Column>
|
<Column field="code" header="Code"></Column>
|
||||||
<Column field="year" header="Year"></Column>
|
<Column field="name" header="Name"></Column>
|
||||||
<Column field="brand" header="Brand"></Column>
|
<Column field="category" header="Category"></Column>
|
||||||
<Column field="color" header="Color"></Column>
|
<Column field="quantity" header="Quantity"></Column>
|
||||||
</DataTable>
|
</DataTable>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<h5>Checkbox</h5>
|
<h5>Checkbox</h5>
|
||||||
<p>Multiple selection can also be handled using checkboxes by enabling the selectionMode property of column as "multiple".</p>
|
<p>Multiple selection can also be handled using checkboxes by enabling the selectionMode property of column as "multiple".</p>
|
||||||
<DataTable :value="cars" :selection.sync="selectedCars3" dataKey="vin">
|
<DataTable :value="products" :selection.sync="selectedProducts3" dataKey="id">
|
||||||
<Column selectionMode="multiple" headerStyle="width: 3em"></Column>
|
<Column selectionMode="multiple" headerStyle="width: 3em"></Column>
|
||||||
<Column field="vin" header="Vin"></Column>
|
<Column field="code" header="Code"></Column>
|
||||||
<Column field="year" header="Year"></Column>
|
<Column field="name" header="Name"></Column>
|
||||||
<Column field="brand" header="Brand"></Column>
|
<Column field="category" header="Category"></Column>
|
||||||
<Column field="color" header="Color"></Column>
|
<Column field="quantity" header="Quantity"></Column>
|
||||||
</DataTable>
|
</DataTable>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -86,98 +86,108 @@
|
||||||
<TabPanel header="Source">
|
<TabPanel header="Source">
|
||||||
<CodeHighlight>
|
<CodeHighlight>
|
||||||
<template v-pre>
|
<template v-pre>
|
||||||
<h5>Single</h3>
|
<div class="card">
|
||||||
<p>In single mode, a row is selected on click event of a row. If the row is already selected then the row gets unselected.</p>
|
<h5>Single</h5>
|
||||||
<DataTable :value="cars" :selection.sync="selectedCar1" selectionMode="single" dataKey="vin">
|
<p>In single mode, a row is selected on click event of a row. If the row is already selected then the row gets unselected.</p>
|
||||||
<Column field="vin" header="Vin"></Column>
|
<DataTable :value="products" :selection.sync="selectedProduct1" selectionMode="single" dataKey="id">
|
||||||
<Column field="year" header="Year"></Column>
|
<Column field="code" header="Code"></Column>
|
||||||
<Column field="brand" header="Brand"></Column>
|
<Column field="name" header="Name"></Column>
|
||||||
<Column field="color" header="Color"></Column>
|
<Column field="category" header="Category"></Column>
|
||||||
</DataTable>
|
<Column field="quantity" header="Quantity"></Column>
|
||||||
|
</DataTable>
|
||||||
|
</div>
|
||||||
|
|
||||||
<h3>Multiple</h3>
|
<div class="card">
|
||||||
<p>In multiple mode, selection binding should be an array. For touch enabled devices, selection is managed by tapping and for other devices metakey or shiftkey are required.
|
<h5>Multiple</h5>
|
||||||
|
<p>In multiple mode, selection binding should be an array. For touch enabled devices, selection is managed by tapping and for other devices metakey or shiftkey are required.
|
||||||
Setting metaKeySelection property as false enables multiple selection without meta key.</p>
|
Setting metaKeySelection property as false enables multiple selection without meta key.</p>
|
||||||
<DataTable :value="cars" :selection.sync="selectedCars1" selectionMode="multiple" dataKey="vin">
|
<DataTable :value="products" :selection.sync="selectedProducts1" selectionMode="multiple" dataKey="id">
|
||||||
<template #header>
|
<template #header>
|
||||||
Multiple Selection with MetaKey
|
Multiple Selection with MetaKey
|
||||||
</template>
|
</template>
|
||||||
<Column field="vin" header="Vin"></Column>
|
<Column field="code" header="Code"></Column>
|
||||||
<Column field="year" header="Year"></Column>
|
<Column field="name" header="Name"></Column>
|
||||||
<Column field="brand" header="Brand"></Column>
|
<Column field="category" header="Category"></Column>
|
||||||
<Column field="color" header="Color"></Column>
|
<Column field="quantity" header="Quantity"></Column>
|
||||||
</DataTable>
|
</DataTable>
|
||||||
|
|
||||||
<DataTable :value="cars" :selection.sync="selectedCars2" selectionMode="multiple" dataKey="vin" :metaKeySelection="false" style="margin-top: 2em">
|
<DataTable :value="products" :selection.sync="selectedProducts2" selectionMode="multiple" dataKey="id" :metaKeySelection="false" style="margin-top: 2em">
|
||||||
<template #header>
|
<template #header>
|
||||||
Multiple Selection without MetaKey
|
Multiple Selection without MetaKey
|
||||||
</template>
|
</template>
|
||||||
<Column field="vin" header="Vin"></Column>
|
<Column field="code" header="Code"></Column>
|
||||||
<Column field="year" header="Year"></Column>
|
<Column field="name" header="Name"></Column>
|
||||||
<Column field="brand" header="Brand"></Column>
|
<Column field="category" header="Category"></Column>
|
||||||
<Column field="color" header="Color"></Column>
|
<Column field="quantity" header="Quantity"></Column>
|
||||||
</DataTable>
|
</DataTable>
|
||||||
|
</div>
|
||||||
|
|
||||||
<h3>Events</h3>
|
<div class="card">
|
||||||
<p>row-select and row-unselects are available as selection events.</p>
|
<h5>Events</h5>
|
||||||
<DataTable :value="cars" :selection.sync="selectedCar2" selectionMode="single" dataKey="vin"
|
<p>row-select and row-unselects are available as selection events.</p>
|
||||||
|
<DataTable :value="products" :selection.sync="selectedProduct2" selectionMode="single" dataKey="id"
|
||||||
@row-select="onRowSelect" @row-unselect="onRowUnselect">
|
@row-select="onRowSelect" @row-unselect="onRowUnselect">
|
||||||
<Column field="vin" header="Vin"></Column>
|
<Column field="code" header="Code"></Column>
|
||||||
<Column field="year" header="Year"></Column>
|
<Column field="name" header="Name"></Column>
|
||||||
<Column field="brand" header="Brand"></Column>
|
<Column field="category" header="Category"></Column>
|
||||||
<Column field="color" header="Color"></Column>
|
<Column field="quantity" header="Quantity"></Column>
|
||||||
</DataTable>
|
</DataTable>
|
||||||
|
</div>
|
||||||
|
|
||||||
<h3>RadioButton</h3>
|
<div class="card">
|
||||||
<p>Single selection can also be handled using radio buttons by enabling the selectionMode property of column as "single".</p>
|
<h5>RadioButton</h5>
|
||||||
<DataTable :value="cars" :selection.sync="selectedCar3" dataKey="vin">
|
<p>Single selection can also be handled using radio buttons by enabling the selectionMode property of column as "single".</p>
|
||||||
|
<DataTable :value="products" :selection.sync="selectedProduct3" dataKey="id">
|
||||||
<Column selectionMode="single" headerStyle="width: 3em"></Column>
|
<Column selectionMode="single" headerStyle="width: 3em"></Column>
|
||||||
<Column field="vin" header="Vin"></Column>
|
<Column field="code" header="Code"></Column>
|
||||||
<Column field="year" header="Year"></Column>
|
<Column field="name" header="Name"></Column>
|
||||||
<Column field="brand" header="Brand"></Column>
|
<Column field="category" header="Category"></Column>
|
||||||
<Column field="color" header="Color"></Column>
|
<Column field="quantity" header="Quantity"></Column>
|
||||||
</DataTable>
|
</DataTable>
|
||||||
|
</div>
|
||||||
|
|
||||||
<h3>Checkbox</h3>
|
<div class="card">
|
||||||
<p>Multiple selection can also be handled using checkboxes by enabling the selectionMode property of column as "multiple".</p>
|
<h5>Checkbox</h5>
|
||||||
<DataTable :value="cars" :selection.sync="selectedCars3" dataKey="vin">
|
<p>Multiple selection can also be handled using checkboxes by enabling the selectionMode property of column as "multiple".</p>
|
||||||
|
<DataTable :value="products" :selection.sync="selectedProducts3" dataKey="id">
|
||||||
<Column selectionMode="multiple" headerStyle="width: 3em"></Column>
|
<Column selectionMode="multiple" headerStyle="width: 3em"></Column>
|
||||||
<Column field="vin" header="Vin"></Column>
|
<Column field="code" header="Code"></Column>
|
||||||
<Column field="year" header="Year"></Column>
|
<Column field="name" header="Name"></Column>
|
||||||
<Column field="brand" header="Brand"></Column>
|
<Column field="category" header="Category"></Column>
|
||||||
<Column field="color" header="Color"></Column>
|
<Column field="quantity" header="Quantity"></Column>
|
||||||
</DataTable>
|
</DataTable>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</CodeHighlight>
|
</CodeHighlight>
|
||||||
|
|
||||||
<CodeHighlight lang="javascript">
|
<CodeHighlight lang="javascript">
|
||||||
import CarService from '../../service/CarService';
|
import ProductService from '../../service/ProductService';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
cars: null,
|
products: null,
|
||||||
selectedCar1: null,
|
selectedProduct1: null,
|
||||||
selectedCar2: null,
|
selectedProduct2: null,
|
||||||
selectedCar3: null,
|
selectedProduct3: null,
|
||||||
selectedCars1: null,
|
selectedProducts1: null,
|
||||||
selectedCars2: null,
|
selectedProducts2: null,
|
||||||
selectedCars3: null
|
selectedProducts3: null
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
carService: null,
|
productService: null,
|
||||||
created() {
|
created() {
|
||||||
this.carService = new CarService();
|
this.productService = new ProductService();
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.carService.getCarsSmall().then(data => this.cars = data);
|
this.productService.getProductsSmall().then(data => this.products = data);
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
onRowSelect(event) {
|
onRowSelect(event) {
|
||||||
this.$toast.add({severity: 'info', summary: 'Car Selected', detail: 'Vin: ' + event.data.vin, life: 3000});
|
this.$toast.add({severity: 'info', summary: 'Product Selected', detail: 'Name: ' + event.data.name, life: 3000});
|
||||||
},
|
},
|
||||||
onRowUnselect(event) {
|
onRowUnselect(event) {
|
||||||
this.$toast.add({severity: 'warn', summary: 'Car Unselected', detail: 'Vin: ' + event.data.vin, life: 3000});
|
this.$toast.add({severity: 'warn', summary: 'Product Unselected', detail: 'Name: ' + event.data.name, life: 3000});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -189,33 +199,33 @@ export default {
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import CarService from '../../service/CarService';
|
import ProductService from '../../service/ProductService';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
cars: null,
|
products: null,
|
||||||
selectedCar1: null,
|
selectedProduct1: null,
|
||||||
selectedCar2: null,
|
selectedProduct2: null,
|
||||||
selectedCar3: null,
|
selectedProduct3: null,
|
||||||
selectedCars1: null,
|
selectedProducts1: null,
|
||||||
selectedCars2: null,
|
selectedProducts2: null,
|
||||||
selectedCars3: null
|
selectedProducts3: null
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
carService: null,
|
productService: null,
|
||||||
created() {
|
created() {
|
||||||
this.carService = new CarService();
|
this.productService = new ProductService();
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.carService.getCarsSmall().then(data => this.cars = data);
|
this.productService.getProductsSmall().then(data => this.products = data);
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
onRowSelect(event) {
|
onRowSelect(event) {
|
||||||
this.$toast.add({severity: 'info', summary: 'Car Selected', detail: 'Vin: ' + event.data.vin, life: 3000});
|
this.$toast.add({severity: 'info', summary: 'Product Selected', detail: 'Name: ' + event.data.name, life: 3000});
|
||||||
},
|
},
|
||||||
onRowUnselect(event) {
|
onRowUnselect(event) {
|
||||||
this.$toast.add({severity: 'warn', summary: 'Car Unselected', detail: 'Vin: ' + event.data.vin, life: 3000});
|
this.$toast.add({severity: 'warn', summary: 'Product Unselected', detail: 'Name: ' + event.data.name, life: 3000});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue