Update row group demo
parent
ffbc27b7f3
commit
ee76eef2ca
|
@ -179,8 +179,8 @@ export default {
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.image-text {
|
.image-text {
|
||||||
visibility: middle;
|
vertical-align: middle;
|
||||||
margin-left: 5rem;
|
margin-left: .5rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.customer-badge {
|
.customer-badge {
|
||||||
|
|
|
@ -333,8 +333,8 @@ export default {
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.image-text {
|
.image-text {
|
||||||
visibility: middle;
|
vertical-align: middle;
|
||||||
margin-left: 5rem;
|
margin-left: .5rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.customer-badge {
|
.customer-badge {
|
||||||
|
|
|
@ -10,58 +10,97 @@
|
||||||
<div class="content-section implementation">
|
<div class="content-section implementation">
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<h5>Subheader Grouping</h5>
|
<h5>Subheader Grouping</h5>
|
||||||
<DataTable :value="cars" rowGroupMode="subheader" groupRowsBy="brand"
|
<p>Group customers by their representative.</p>
|
||||||
sortMode="single" sortField="brand" :sortOrder="1">
|
<DataTable :value="customers" rowGroupMode="subheader" groupRowsBy="representative.name"
|
||||||
<Column field="brand" header="Brand"></Column>
|
sortMode="single" sortField="representative.name" :sortOrder="1">
|
||||||
<Column field="vin" header="Vin"></Column>
|
<Column field="representative.name" header="Representative"></Column>
|
||||||
<Column field="year" header="Year"></Column>
|
<Column field="name" header="Name"></Column>
|
||||||
<Column field="color" header="Color"></Column>
|
<Column field="country" header="Country">
|
||||||
<Column field="price" header="Price"></Column>
|
<template #body="slotProps">
|
||||||
|
<img src="../../assets/images/flag_placeholder.png" :class="'flag flag-' + slotProps.data.country.code" width="30" />
|
||||||
|
<span class="image-text">{{slotProps.data.country.name}}</span>
|
||||||
|
</template>
|
||||||
|
</Column>
|
||||||
|
<Column field="company" header="Company"></Column>
|
||||||
|
<Column field="status" header="Status">
|
||||||
|
<template #body="slotProps">
|
||||||
|
<span :class="'customer-badge status-' + slotProps.data.status">{{slotProps.data.status}}</span>
|
||||||
|
</template>
|
||||||
|
</Column>
|
||||||
|
<Column field="date" header="date"></Column>
|
||||||
<template #groupheader="slotProps">
|
<template #groupheader="slotProps">
|
||||||
<span>{{slotProps.data.brand}}</span>
|
<img :alt="slotProps.data.representative.name" :src="'demo/images/avatar/' + slotProps.data.representative.image" width="32" style="vertical-align: middle" />
|
||||||
|
<span class="image-text">{{slotProps.data.representative.name}}</span>
|
||||||
</template>
|
</template>
|
||||||
<template #groupfooter="slotProps">
|
<template #groupfooter="slotProps">
|
||||||
<td colspan="3" style="text-align: right">Total Price</td>
|
<td colspan="4" style="text-align: right">Total Customers</td>
|
||||||
<td>{{calculateGroupTotal(slotProps.data.brand)}}</td>
|
<td>{{calculateCustomerTotal(slotProps.data.representative.name)}}</td>
|
||||||
</template>
|
</template>
|
||||||
</DataTable>
|
</DataTable>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<h5>Expandable Row Groups</h5>
|
<h5>Expandable Row Groups</h5>
|
||||||
<DataTable :value="cars" rowGroupMode="subheader" groupRowsBy="brand"
|
<p>Group customers by their representative.</p>
|
||||||
sortMode="single" sortField="brand" :sortOrder="1"
|
<DataTable :value="customers" rowGroupMode="subheader" groupRowsBy="representative.name"
|
||||||
|
sortMode="single" sortField="representative.name" :sortOrder="1"
|
||||||
:expandableRowGroups="true" :expandedRowGroups.sync="expandedRowGroups"
|
:expandableRowGroups="true" :expandedRowGroups.sync="expandedRowGroups"
|
||||||
@rowgroup-expand="onRowGroupExpand" @rowgroup-collapse="onRowGroupCollapse">
|
@rowgroup-expand="onRowGroupExpand" @rowgroup-collapse="onRowGroupCollapse">
|
||||||
<Column field="brand" header="Brand"></Column>
|
<Column field="representative.name" header="Representative"></Column>
|
||||||
<Column field="vin" header="Vin"></Column>
|
<Column field="name" header="Name"></Column>
|
||||||
<Column field="year" header="Year"></Column>
|
<Column field="country" header="Country">
|
||||||
<Column field="color" header="Color"></Column>
|
<template #body="slotProps">
|
||||||
<Column field="price" header="Price"></Column>
|
<img src="../../assets/images/flag_placeholder.png" :class="'flag flag-' + slotProps.data.country.code" width="30" />
|
||||||
|
<span class="image-text">{{slotProps.data.country.name}}</span>
|
||||||
|
</template>
|
||||||
|
</Column>
|
||||||
|
<Column field="company" header="Company"></Column>
|
||||||
|
<Column field="status" header="Status">
|
||||||
|
<template #body="slotProps">
|
||||||
|
<span :class="'customer-badge status-' + slotProps.data.status">{{slotProps.data.status}}</span>
|
||||||
|
</template>
|
||||||
|
</Column>
|
||||||
|
<Column field="date" header="date"></Column>
|
||||||
<template #groupheader="slotProps">
|
<template #groupheader="slotProps">
|
||||||
<span>{{slotProps.data.brand}}</span>
|
<img :alt="slotProps.data.representative.name" :src="'demo/images/avatar/' + slotProps.data.representative.image" width="32" style="vertical-align: middle" />
|
||||||
|
<span class="image-text">{{slotProps.data.representative.name}}</span>
|
||||||
</template>
|
</template>
|
||||||
<template #groupfooter="slotProps">
|
<template #groupfooter="slotProps">
|
||||||
<td colspan="3" style="text-align: right">Total Price</td>
|
<td colspan="4" style="text-align: right">Total Customers</td>
|
||||||
<td>{{calculateGroupTotal(slotProps.data.brand)}}</td>
|
<td>{{calculateCustomerTotal(slotProps.data.representative.name)}}</td>
|
||||||
</template>
|
</template>
|
||||||
</DataTable>
|
</DataTable>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<h5>RowSpan Grouping</h5>
|
<h5>RowSpan Grouping</h5>
|
||||||
<DataTable :value="cars" rowGroupMode="rowspan" groupRowsBy="brand"
|
<DataTable :value="customers" rowGroupMode="rowspan" groupRowsBy="representative.name"
|
||||||
sortMode="single" sortField="brand" :sortOrder="1">
|
sortMode="single" sortField="representative.name" :sortOrder="1">
|
||||||
<Column header="#" headerStyle="width:3em">
|
<Column header="#" headerStyle="width:3em">
|
||||||
<template #body="slotProps">
|
<template #body="slotProps">
|
||||||
{{slotProps.index}}
|
{{slotProps.index}}
|
||||||
</template>
|
</template>
|
||||||
</Column>
|
</Column>
|
||||||
<Column field="brand" header="Brand"></Column>
|
<Column field="representative.name" header="Representative">
|
||||||
<Column field="year" header="Year"></Column>
|
<template #body="slotProps">
|
||||||
<Column field="vin" header="Vin"></Column>
|
<img :alt="slotProps.data.representative.name" :src="'demo/images/avatar/' + slotProps.data.representative.image" width="32" style="vertical-align: middle" />
|
||||||
<Column field="color" header="Color"></Column>
|
<span class="image-text">{{slotProps.data.representative.name}}</span>
|
||||||
<Column field="price" header="Price"></Column>
|
</template>
|
||||||
|
</Column>
|
||||||
|
<Column field="name" header="Name"></Column>
|
||||||
|
<Column field="country" header="Country">
|
||||||
|
<template #body="slotProps">
|
||||||
|
<img src="../../assets/images/flag_placeholder.png" :class="'flag flag-' + slotProps.data.country.code" width="30" />
|
||||||
|
<span class="image-text">{{slotProps.data.country.name}}</span>
|
||||||
|
</template>
|
||||||
|
</Column>
|
||||||
|
<Column field="company" header="Company"></Column>
|
||||||
|
<Column field="status" header="Status">
|
||||||
|
<template #body="slotProps">
|
||||||
|
<span :class="'customer-badge status-' + slotProps.data.status">{{slotProps.data.status}}</span>
|
||||||
|
</template>
|
||||||
|
</Column>
|
||||||
|
<Column field="date" header="date"></Column>
|
||||||
</DataTable>
|
</DataTable>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -71,75 +110,120 @@
|
||||||
<TabPanel header="Source">
|
<TabPanel header="Source">
|
||||||
<CodeHighlight>
|
<CodeHighlight>
|
||||||
<template v-pre>
|
<template v-pre>
|
||||||
<h3>Subheader Grouping</h3>
|
<div class="card">
|
||||||
<DataTable :value="cars" rowGroupMode="subheader" groupRowsBy="brand"
|
<h5>Subheader Grouping</h5>
|
||||||
sortMode="single" sortField="brand" :sortOrder="1">
|
<p>Group customers by their representative.</p>
|
||||||
<Column field="brand" header="Brand"></Column>
|
<DataTable :value="customers" rowGroupMode="subheader" groupRowsBy="representative.name"
|
||||||
<Column field="vin" header="Vin"></Column>
|
sortMode="single" sortField="representative.name" :sortOrder="1">
|
||||||
<Column field="year" header="Year"></Column>
|
<Column field="representative.name" header="Representative"></Column>
|
||||||
<Column field="color" header="Color"></Column>
|
<Column field="name" header="Name"></Column>
|
||||||
<Column field="price" header="Price"></Column>
|
<Column field="country" header="Country">
|
||||||
<template #groupheader="slotProps">
|
|
||||||
<span>{{slotProps.data.brand}}</span>
|
|
||||||
</template>
|
|
||||||
<template #groupfooter="slotProps">
|
|
||||||
<td colspan="3" style="text-align: right">Total Price</td>
|
|
||||||
<td>{{calculateGroupTotal(slotProps.data.brand)}}</td>
|
|
||||||
</template>
|
|
||||||
</DataTable>
|
|
||||||
|
|
||||||
<h3>Expandable Row Groups</h3>
|
|
||||||
<DataTable :value="cars" rowGroupMode="subheader" groupRowsBy="brand"
|
|
||||||
sortMode="single" sortField="brand" :sortOrder="1"
|
|
||||||
:expandableRowGroups="true" :expandedRowGroups.sync="expandedRowGroups"
|
|
||||||
@rowgroup-expand="onRowExpand" @rowgroup-collapse="onRowCollapse">
|
|
||||||
<Column field="brand" header="Brand"></Column>
|
|
||||||
<Column field="vin" header="Vin"></Column>
|
|
||||||
<Column field="year" header="Year"></Column>
|
|
||||||
<Column field="color" header="Color"></Column>
|
|
||||||
<Column field="price" header="Price"></Column>
|
|
||||||
<template #groupheader="slotProps">
|
|
||||||
<span>{{slotProps.data.brand}}</span>
|
|
||||||
</template>
|
|
||||||
<template #groupfooter="slotProps">
|
|
||||||
<td colspan="3" style="text-align: right">Total Price</td>
|
|
||||||
<td>{{calculateGroupTotal(slotProps.data.brand)}}</td>
|
|
||||||
</template>
|
|
||||||
</DataTable>
|
|
||||||
|
|
||||||
<h3>RowSpan Grouping</h3>
|
|
||||||
<DataTable :value="cars" rowGroupMode="rowspan" groupRowsBy="brand"
|
|
||||||
sortMode="single" sortField="brand" :sortOrder="1">
|
|
||||||
<Column header="#" headerStyle="width:3em">
|
|
||||||
<template #body="slotProps">
|
<template #body="slotProps">
|
||||||
{{slotProps.index}}
|
<img src="../../assets/images/flag_placeholder.png" :class="'flag flag-' + slotProps.data.country.code" width="30" />
|
||||||
|
<span class="image-text">{{slotProps.data.country.name}}</span>
|
||||||
</template>
|
</template>
|
||||||
</Column>
|
</Column>
|
||||||
<Column field="brand" header="Brand"></Column>
|
<Column field="company" header="Company"></Column>
|
||||||
<Column field="year" header="Year"></Column>
|
<Column field="status" header="Status">
|
||||||
<Column field="vin" header="Vin"></Column>
|
<template #body="slotProps">
|
||||||
<Column field="color" header="Color"></Column>
|
<span :class="'customer-badge status-' + slotProps.data.status">{{slotProps.data.status}}</span>
|
||||||
<Column field="price" header="Price"></Column>
|
</template>
|
||||||
</DataTable>
|
</Column>
|
||||||
|
<Column field="date" header="date"></Column>
|
||||||
|
<template #groupheader="slotProps">
|
||||||
|
<img :alt="slotProps.data.representative.name" :src="'demo/images/avatar/' + slotProps.data.representative.image" width="32" style="vertical-align: middle" />
|
||||||
|
<span class="image-text">{{slotProps.data.representative.name}}</span>
|
||||||
|
</template>
|
||||||
|
<template #groupfooter="slotProps">
|
||||||
|
<td colspan="4" style="text-align: right">Total Customers</td>
|
||||||
|
<td>{{calculateCustomerTotal(slotProps.data.representative.name)}}</td>
|
||||||
|
</template>
|
||||||
|
</DataTable>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="card">
|
||||||
|
<h5>Expandable Row Groups</h5>
|
||||||
|
<p>Group customers by their representative.</p>
|
||||||
|
<DataTable :value="customers" rowGroupMode="subheader" groupRowsBy="representative.name"
|
||||||
|
sortMode="single" sortField="representative.name" :sortOrder="1"
|
||||||
|
:expandableRowGroups="true" :expandedRowGroups.sync="expandedRowGroups"
|
||||||
|
@rowgroup-expand="onRowGroupExpand" @rowgroup-collapse="onRowGroupCollapse">
|
||||||
|
<Column field="representative.name" header="Representative"></Column>
|
||||||
|
<Column field="name" header="Name"></Column>
|
||||||
|
<Column field="country" header="Country">
|
||||||
|
<template #body="slotProps">
|
||||||
|
<img src="../../assets/images/flag_placeholder.png" :class="'flag flag-' + slotProps.data.country.code" width="30" />
|
||||||
|
<span class="image-text">{{slotProps.data.country.name}}</span>
|
||||||
|
</template>
|
||||||
|
</Column>
|
||||||
|
<Column field="company" header="Company"></Column>
|
||||||
|
<Column field="status" header="Status">
|
||||||
|
<template #body="slotProps">
|
||||||
|
<span :class="'customer-badge status-' + slotProps.data.status">{{slotProps.data.status}}</span>
|
||||||
|
</template>
|
||||||
|
</Column>
|
||||||
|
<Column field="date" header="date"></Column>
|
||||||
|
<template #groupheader="slotProps">
|
||||||
|
<img :alt="slotProps.data.representative.name" :src="'demo/images/avatar/' + slotProps.data.representative.image" width="32" style="vertical-align: middle" />
|
||||||
|
<span class="image-text">{{slotProps.data.representative.name}}</span>
|
||||||
|
</template>
|
||||||
|
<template #groupfooter="slotProps">
|
||||||
|
<td colspan="4" style="text-align: right">Total Customers</td>
|
||||||
|
<td>{{calculateCustomerTotal(slotProps.data.representative.name)}}</td>
|
||||||
|
</template>
|
||||||
|
</DataTable>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="card">
|
||||||
|
<h5>RowSpan Grouping</h5>
|
||||||
|
<DataTable :value="customers" rowGroupMode="rowspan" groupRowsBy="representative.name"
|
||||||
|
sortMode="single" sortField="representative.name" :sortOrder="1">
|
||||||
|
<Column header="#" headerStyle="width:3em">
|
||||||
|
<template #body="slotProps">
|
||||||
|
{{slotProps.index}}
|
||||||
|
</template>
|
||||||
|
</Column>
|
||||||
|
<Column field="representative.name" header="Representative">
|
||||||
|
<template #body="slotProps">
|
||||||
|
<img :alt="slotProps.data.representative.name" :src="'demo/images/avatar/' + slotProps.data.representative.image" width="32" style="vertical-align: middle" />
|
||||||
|
<span class="image-text">{{slotProps.data.representative.name}}</span>
|
||||||
|
</template>
|
||||||
|
</Column>
|
||||||
|
<Column field="name" header="Name"></Column>
|
||||||
|
<Column field="country" header="Country">
|
||||||
|
<template #body="slotProps">
|
||||||
|
<img src="../../assets/images/flag_placeholder.png" :class="'flag flag-' + slotProps.data.country.code" width="30" />
|
||||||
|
<span class="image-text">{{slotProps.data.country.name}}</span>
|
||||||
|
</template>
|
||||||
|
</Column>
|
||||||
|
<Column field="company" header="Company"></Column>
|
||||||
|
<Column field="status" header="Status">
|
||||||
|
<template #body="slotProps">
|
||||||
|
<span :class="'customer-badge status-' + slotProps.data.status">{{slotProps.data.status}}</span>
|
||||||
|
</template>
|
||||||
|
</Column>
|
||||||
|
<Column field="date" header="date"></Column>
|
||||||
|
</DataTable>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</CodeHighlight>
|
</CodeHighlight>
|
||||||
|
|
||||||
<CodeHighlight lang="javascript">
|
<CodeHighlight lang="javascript">
|
||||||
import CarService from '../../service/CarService';
|
import CustomerService from '../../service/CustomerService';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
cars: null,
|
customers: null,
|
||||||
expandedRowGroups: null
|
expandedRowGroups: null
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
carService: null,
|
customerService: null,
|
||||||
created() {
|
created() {
|
||||||
this.carService = new CarService();
|
this.customerService = new CustomerService();
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.carService.getCarsMedium().then(data => this.cars = data);
|
this.customerService.getCustomersMedium().then(data => this.customers = data);
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
onRowGroupExpand(event) {
|
onRowGroupExpand(event) {
|
||||||
|
@ -148,13 +232,13 @@ export default {
|
||||||
onRowGroupCollapse(event) {
|
onRowGroupCollapse(event) {
|
||||||
this.$toast.add({severity: 'success', summary: 'Row Group Collapsed', detail: 'Value: ' + event.data, life: 3000});
|
this.$toast.add({severity: 'success', summary: 'Row Group Collapsed', detail: 'Value: ' + event.data, life: 3000});
|
||||||
},
|
},
|
||||||
calculateGroupTotal(brand) {
|
calculateCustomerTotal(name) {
|
||||||
let total = 0;
|
let total = 0;
|
||||||
|
|
||||||
if (this.cars) {
|
if (this.customers) {
|
||||||
for (let car of this.cars) {
|
for (let customer of this.customers) {
|
||||||
if (car.brand === brand) {
|
if (customer.representative.name === name) {
|
||||||
total += car.price;
|
total++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -171,21 +255,21 @@ export default {
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import CarService from '../../service/CarService';
|
import CustomerService from '../../service/CustomerService';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
cars: null,
|
customers: null,
|
||||||
expandedRowGroups: null
|
expandedRowGroups: null
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
carService: null,
|
customerService: null,
|
||||||
created() {
|
created() {
|
||||||
this.carService = new CarService();
|
this.customerService = new CustomerService();
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.carService.getCarsMedium().then(data => this.cars = data);
|
this.customerService.getCustomersMedium().then(data => this.customers = data);
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
onRowGroupExpand(event) {
|
onRowGroupExpand(event) {
|
||||||
|
@ -194,13 +278,13 @@ export default {
|
||||||
onRowGroupCollapse(event) {
|
onRowGroupCollapse(event) {
|
||||||
this.$toast.add({severity: 'success', summary: 'Row Group Collapsed', detail: 'Value: ' + event.data, life: 3000});
|
this.$toast.add({severity: 'success', summary: 'Row Group Collapsed', detail: 'Value: ' + event.data, life: 3000});
|
||||||
},
|
},
|
||||||
calculateGroupTotal(brand) {
|
calculateCustomerTotal(name) {
|
||||||
let total = 0;
|
let total = 0;
|
||||||
|
|
||||||
if (this.cars) {
|
if (this.customers) {
|
||||||
for (let car of this.cars) {
|
for (let customer of this.customers) {
|
||||||
if (car.brand === brand) {
|
if (customer.representative.name === name) {
|
||||||
total += car.price;
|
total++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -212,6 +296,50 @@ export default {
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
.customer-badge {
|
||||||
|
border-radius: 2px;
|
||||||
|
padding: .25em .5rem;
|
||||||
|
text-transform: uppercase;
|
||||||
|
font-weight: 700;
|
||||||
|
font-size: 12px;
|
||||||
|
letter-spacing: .3px;
|
||||||
|
|
||||||
|
&.status-qualified {
|
||||||
|
background-color: #C8E6C9;
|
||||||
|
color: #256029;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.status-unqualified {
|
||||||
|
background-color: #FFCDD2;
|
||||||
|
color: #C63737;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.status-negotiation {
|
||||||
|
background-color: #FEEDAF;
|
||||||
|
color: #8A5340;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.status-new {
|
||||||
|
background-color: #B3E5FC;
|
||||||
|
color: #23547B;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.status-renewal {
|
||||||
|
background-color: #ECCFFF;
|
||||||
|
color: #694382;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.status-proposal {
|
||||||
|
background-color: #FFD8B2;
|
||||||
|
color: #805B36;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.image-text {
|
||||||
|
vertical-align: middle;
|
||||||
|
margin-left: .5rem;
|
||||||
|
}
|
||||||
|
|
||||||
.p-rowgroup-footer td {
|
.p-rowgroup-footer td {
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
}
|
}
|
||||||
|
@ -226,6 +354,4 @@ export default {
|
||||||
margin-right: .25rem;
|
margin-right: .25rem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
</style>
|
</style>
|
Loading…
Reference in New Issue