primevue-mirror/doc/inplace/LazyDoc.vue

108 lines
3.3 KiB
Vue
Raw Normal View History

2023-02-28 08:29:30 +00:00
<template>
<DocSectionText v-bind="$attrs">
<p>Using the <i>open</i> event, data can be loaded in a lazy manner before displaying it in a table.</p>
</DocSectionText>
<div class="card">
<Inplace @open="loadData">
<template #display> View Data </template>
<template #content>
<DataTable :value="products">
<Column field="code" header="Code"></Column>
<Column field="name" header="Name"></Column>
<Column field="category" header="Category"></Column>
<Column field="quantity" header="Quantity"></Column>
</DataTable>
</template>
</Inplace>
</div>
<DocSectionCode :code="code" :service="['ProductService']" />
</template>
<script>
import { ProductService } from '@/service/ProductService';
export default {
data() {
return {
products: null,
code: {
2023-08-16 13:58:31 +00:00
basic: `<Inplace @open="loadData">
2023-02-28 08:29:30 +00:00
<template #display> View Data </template>
<template #content>
<DataTable :value="products">
<Column field="code" header="Code"></Column>
<Column field="name" header="Name"></Column>
<Column field="category" header="Category"></Column>
<Column field="quantity" header="Quantity"></Column>
</DataTable>
</template>
</Inplace>`,
2023-08-16 13:58:31 +00:00
options: `<template>
2023-02-28 08:29:30 +00:00
<div class="card">
<Inplace @open="loadData">
<template #display> View Data </template>
<template #content>
<DataTable :value="products">
<Column field="code" header="Code"></Column>
<Column field="name" header="Name"></Column>
<Column field="category" header="Category"></Column>
<Column field="quantity" header="Quantity"></Column>
</DataTable>
</template>
</Inplace>
</div>
</template>
<script>
import {ProductService} from '@/service/ProductService';
export default {
data() {
return {
products: null
}
},
methods: {
loadData() {
ProductService.getProductsSmall().then((data) => (this.products = data));
}
}
}
<\/script>`,
2023-08-16 13:58:31 +00:00
composition: `<template>
2023-02-28 08:29:30 +00:00
<div class="card">
<Inplace @open="loadData">
<template #display> View Data </template>
<template #content>
<DataTable :value="products">
<Column field="code" header="Code"></Column>
<Column field="name" header="Name"></Column>
<Column field="category" header="Category"></Column>
<Column field="quantity" header="Quantity"></Column>
</DataTable>
</template>
</Inplace>
</div>
</template>
<script setup>
import { ref } from "vue";
import {ProductService} from "@/service/ProductService";
const products = ref();
const loadData = () => {
ProductService.getProductsSmall().then((data) => (products.value = data));
}
<\/script>`
}
};
},
methods: {
loadData() {
ProductService.getProductsSmall().then((data) => (this.products = data));
}
}
};
</script>