Fixed #4229 - Datatable: Filtering with grouping not working
parent
2e9e12ee6e
commit
bdb266092a
|
@ -281,7 +281,7 @@ const classes = {
|
||||||
thead: 'p-datatable-thead',
|
thead: 'p-datatable-thead',
|
||||||
// headercell
|
// headercell
|
||||||
headerCell: ({ instance, props, column }) =>
|
headerCell: ({ instance, props, column }) =>
|
||||||
column && !instance.columnProp(column, 'hidden') && (props.rowGroupMode !== 'subheader' || props.groupRowsBy !== columnProp(column, 'field'))
|
column && !instance.columnProp(column, 'hidden') && (props.rowGroupMode !== 'subheader' || props.groupRowsBy !== instance.columnProp(column, 'field'))
|
||||||
? [
|
? [
|
||||||
'p-filter-column',
|
'p-filter-column',
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,72 +1,79 @@
|
||||||
<template>
|
|
||||||
<DocSectionText v-bind="$attrs">
|
|
||||||
<p>A simple Card is created with a <i>title</i> property along with the content as children.</p>
|
|
||||||
</DocSectionText>
|
|
||||||
<div class="card">
|
|
||||||
<Card>
|
|
||||||
<template #title> Simple Card </template>
|
|
||||||
<template #content>
|
|
||||||
<p>
|
|
||||||
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Inventore sed consequuntur error repudiandae numquam deserunt quisquam repellat libero asperiores earum nam nobis, culpa ratione quam perferendis esse, cupiditate neque
|
|
||||||
quas!
|
|
||||||
</p>
|
|
||||||
</template>
|
|
||||||
</Card>
|
|
||||||
</div>
|
|
||||||
<DocSectionCode :code="code" />
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
export default {
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
code: {
|
|
||||||
basic: `
|
|
||||||
<Card>
|
|
||||||
<template #title> Simple Card </template>
|
|
||||||
<template #content>
|
|
||||||
<p>
|
|
||||||
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Inventore sed consequuntur error repudiandae numquam deserunt quisquam repellat libero asperiores earum nam nobis, culpa ratione quam perferendis esse, cupiditate neque
|
|
||||||
quas!
|
|
||||||
</p>
|
|
||||||
</template>
|
|
||||||
</Card>`,
|
|
||||||
options: `
|
|
||||||
<template>
|
<template>
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<Card>
|
<DataTable filterDisplay="row" :value="customers" rowGroupMode="subheader" groupRowsBy="representative.name" sortMode="single" sortField="representative.name" :sortOrder="1" scrollable scrollHeight="400px" tableStyle="min-width: 50rem">
|
||||||
<template #title> Simple Card </template>
|
<Column field="representative.name" header="Representative"></Column>
|
||||||
<template #content>
|
<Column field="name" header="Name" style="min-width: 200px"></Column>
|
||||||
<p>
|
<Column field="country" header="Country" style="min-width: 200px">
|
||||||
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Inventore sed consequuntur error repudiandae numquam deserunt quisquam repellat libero asperiores earum nam nobis, culpa ratione quam perferendis esse, cupiditate neque
|
<template #body="slotProps">
|
||||||
quas!
|
<div class="flex align-items-center gap-2">
|
||||||
</p>
|
<img alt="flag" src="https://primefaces.org/cdn/primevue/images/flag/flag_placeholder.png" :class="`flag flag-${slotProps.data.country.code}`" style="width: 24px" />
|
||||||
</template>
|
<span>{{ slotProps.data.country.name }}</span>
|
||||||
</Card>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
</Column>
|
||||||
<script>
|
<Column field="company" header="Company" style="min-width: 200px"></Column>
|
||||||
<\/script>`,
|
<Column field="status" header="Status" style="min-width: 200px">
|
||||||
composition: `
|
<template #body="slotProps">
|
||||||
<template>
|
<Tag :value="slotProps.data.status" :severity="getSeverity(slotProps.data.status)" />
|
||||||
<div class="card">
|
|
||||||
<Card>
|
|
||||||
<template #title> Simple Card </template>
|
|
||||||
<template #content>
|
|
||||||
<p>
|
|
||||||
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Inventore sed consequuntur error repudiandae numquam deserunt quisquam repellat libero asperiores earum nam nobis, culpa ratione quam perferendis esse, cupiditate neque
|
|
||||||
quas!
|
|
||||||
</p>
|
|
||||||
</template>
|
</template>
|
||||||
</Card>
|
</Column>
|
||||||
|
<Column field="date" header="Date" style="min-width: 200px"></Column>
|
||||||
|
<template #groupheader="slotProps">
|
||||||
|
<div class="flex align-items-center gap-2">
|
||||||
|
<img :alt="slotProps.data.representative.name" :src="`https://primefaces.org/cdn/primevue/images/avatar/${slotProps.data.representative.image}`" width="32" style="vertical-align: middle" />
|
||||||
|
<span>{{ slotProps.data.representative.name }}</span>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<template #groupfooter="slotProps">
|
||||||
|
<div class="flex justify-content-end font-bold w-full">
|
||||||
|
Total Customers:
|
||||||
|
{{ calculateCustomerTotal(slotProps.data.representative.name) }}
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</DataTable>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
<\/script>`
|
import { CustomerService } from '@/service/CustomerService';
|
||||||
|
import { onMounted, ref } from 'vue';
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
CustomerService.getCustomersMedium().then((data) => (customers.value = data));
|
||||||
|
});
|
||||||
|
|
||||||
|
const customers = ref();
|
||||||
|
|
||||||
|
const calculateCustomerTotal = (name) => {
|
||||||
|
let total = 0;
|
||||||
|
|
||||||
|
if (customers.value) {
|
||||||
|
for (let customer of customers.value) {
|
||||||
|
if (customer.representative.name === name) {
|
||||||
|
total++;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return total;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const getSeverity = (status) => {
|
||||||
|
switch (status) {
|
||||||
|
case 'unqualified':
|
||||||
|
return 'danger';
|
||||||
|
|
||||||
|
case 'qualified':
|
||||||
|
return 'success';
|
||||||
|
|
||||||
|
case 'new':
|
||||||
|
return 'info';
|
||||||
|
|
||||||
|
case 'negotiation':
|
||||||
|
return 'warning';
|
||||||
|
|
||||||
|
case 'renewal':
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Reference in New Issue