mirror of
https://github.com/primefaces/primevue.git
synced 2025-05-09 08:52:34 +00:00
Merged new Docs and Demos
This commit is contained in:
parent
296cc217fb
commit
dfcc8ef4e7
1235 changed files with 130757 additions and 122640 deletions
169
doc/datatable/ConditionalStyleDoc.vue
Normal file
169
doc/datatable/ConditionalStyleDoc.vue
Normal file
|
@ -0,0 +1,169 @@
|
|||
<template>
|
||||
<DocSectionText v-bind="$attrs">
|
||||
<p>Particular rows and cells can be styled based on conditions. The <i>rowClass</i> receives a row data as a parameter to return a style class for a row whereas cells are customized using the <i>body</i> template.</p>
|
||||
</DocSectionText>
|
||||
<div class="card">
|
||||
<DataTable :value="products" :rowClass="rowClass" tableStyle="min-width: 50rem">
|
||||
<Column field="code" header="Code"></Column>
|
||||
<Column field="name" header="Name"></Column>
|
||||
<Column field="category" header="Category"></Column>
|
||||
<Column field="quantity" header="Quantity">
|
||||
<template #body="slotProps">
|
||||
<div :class="stockClass(slotProps.data)">
|
||||
{{ slotProps.data.quantity }}
|
||||
</div>
|
||||
</template>
|
||||
</Column>
|
||||
</DataTable>
|
||||
</div>
|
||||
<DocSectionCode :code="code" :service="['ProductService']" />
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { ProductService } from '@/service/ProductService';
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
products: null,
|
||||
code: {
|
||||
basic: `
|
||||
<DataTable :value="products" :rowClass="rowClass" tableStyle="min-width: 50rem">
|
||||
<Column field="code" header="Code"></Column>
|
||||
<Column field="name" header="Name"></Column>
|
||||
<Column field="category" header="Category"></Column>
|
||||
<Column field="quantity" header="Quantity">
|
||||
<template #body="slotProps">
|
||||
<div :class="stockClass(slotProps.data)">
|
||||
{{ slotProps.data.quantity }}
|
||||
</div>
|
||||
</template>
|
||||
</Column>
|
||||
</DataTable>`,
|
||||
options: `
|
||||
<template>
|
||||
<div class="card">
|
||||
<DataTable :value="products" :rowClass="rowClass" tableStyle="min-width: 50rem">
|
||||
<Column field="code" header="Code"></Column>
|
||||
<Column field="name" header="Name"></Column>
|
||||
<Column field="category" header="Category"></Column>
|
||||
<Column field="quantity" header="Quantity">
|
||||
<template #body="slotProps">
|
||||
<div :class="stockClass(slotProps.data)">
|
||||
{{ slotProps.data.quantity }}
|
||||
</div>
|
||||
</template>
|
||||
</Column>
|
||||
</DataTable>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { ProductService } from '@/service/ProductService';
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
products: null
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
ProductService.getProductsSmall().then((data) => (this.products = data));
|
||||
},
|
||||
methods: {
|
||||
rowClass(data) {
|
||||
return [{ 'bg-primary': data.category === 'Fitness' }];
|
||||
},
|
||||
stockClass(data) {
|
||||
return [
|
||||
'border-circle w-2rem h-2rem inline-flex font-bold justify-content-center align-items-center text-sm',
|
||||
{
|
||||
'bg-red-100 text-red-900': data.quantity === 0,
|
||||
'bg-blue-100 text-blue-900': data.quantity > 0 && data.quantity < 10,
|
||||
'bg-teal-100 text-teal-900': data.quantity > 10
|
||||
}
|
||||
];
|
||||
}
|
||||
}
|
||||
};
|
||||
<\/script>`,
|
||||
composition: `
|
||||
<template>
|
||||
<div class="card">
|
||||
<DataTable :value="products" :rowClass="rowClass" tableStyle="min-width: 50rem">
|
||||
<Column field="code" header="Code"></Column>
|
||||
<Column field="name" header="Name"></Column>
|
||||
<Column field="category" header="Category"></Column>
|
||||
<Column field="quantity" header="Quantity">
|
||||
<template #body="slotProps">
|
||||
<div :class="stockClass(slotProps.data)">
|
||||
{{ slotProps.data.quantity }}
|
||||
</div>
|
||||
</template>
|
||||
</Column>
|
||||
</DataTable>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, onMounted } from 'vue';
|
||||
import { ProductService } from '@/service/ProductService';
|
||||
|
||||
onMounted(() => {
|
||||
ProductService.getProductsSmall().then((data) => (this.products = data));
|
||||
});
|
||||
|
||||
const products = ref();
|
||||
|
||||
const rowClass = (data) => {
|
||||
return [{ 'bg-primary': data.category === 'Fitness' }];
|
||||
};
|
||||
const stockClass = (data) => {
|
||||
return [
|
||||
'border-circle w-2rem h-2rem inline-flex font-bold justify-content-center align-items-center text-sm',
|
||||
{
|
||||
'bg-red-100 text-red-900': data.quantity === 0,
|
||||
'bg-blue-100 text-blue-900': data.quantity > 0 && data.quantity < 10,
|
||||
'bg-teal-100 text-teal-900': data.quantity > 10
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
<\/script>`,
|
||||
data: `
|
||||
{
|
||||
id: '1000',
|
||||
code: 'f230fh0g3',
|
||||
name: 'Bamboo Watch',
|
||||
description: 'Product Description',
|
||||
image: 'bamboo-watch.jpg',
|
||||
price: 65,
|
||||
category: 'Accessories',
|
||||
quantity: 24,
|
||||
inventoryStatus: 'INSTOCK',
|
||||
rating: 5
|
||||
},
|
||||
...`
|
||||
}
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
ProductService.getProductsSmall().then((data) => (this.products = data));
|
||||
},
|
||||
methods: {
|
||||
rowClass(data) {
|
||||
return [{ 'bg-primary': data.category === 'Fitness' }];
|
||||
},
|
||||
stockClass(data) {
|
||||
return [
|
||||
'border-circle w-2rem h-2rem inline-flex font-bold justify-content-center align-items-center text-sm',
|
||||
{
|
||||
'bg-red-100 text-red-900': data.quantity === 0,
|
||||
'bg-blue-100 text-blue-900': data.quantity > 0 && data.quantity < 10,
|
||||
'bg-teal-100 text-teal-900': data.quantity > 10
|
||||
}
|
||||
];
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue