Skip to main content

DataTable

DataTable#

Props#

Prop nameDescriptionTypeValuesDefault
headersAn array of objects that each describe a header columnArray-
itemsThe array of items to displayArray-
totalNumber total of elements on querynumber-0
last-pageLast page numbernumber-1
loadingDisplay loading stateboolean-false
btn-action-pathAction pathstring-
to-viewRoute for view action
Denotes the target route of the link. You can find more information about
the to prop on the vue-router documentation.
union-
to-updateRoute for update action
Denotes the target route of the link. You can find more information about
the to prop on the vue-router documentation.
union-
to-action-item-key-idAction item identification key. Used with to-update and to-viewstring-"id"
btn-action-item-key-idAction item identification keystring-"id"
route-name-separatorRoute name separator.
Used to generate update/view routes.
string-"."
is-route-nameUse path prop as route name
Used to generate update/view routes.
boolean-
hide-btn-action-viewHide button view actionboolean-
hide-btn-action-updateHide button edit/update actionboolean-
hide-btn-action-deleteHide button delete actionboolean-
icon-action-viewAction view iconstring-"mdi-eye"
icon-action-editAction edit/update iconstring-"mdi-pencil"
icon-action-deleteAction delete iconstring-"mdi-delete"

Events#

Event namePropertiesDescription
deletesItemId numberItem ID to be deleted

Slots#

NameDescriptionBindings
default

<template>
<data-table
:headers="headers"
:items="obCollection.getModelList()"
:options.sync="pagination"
:total="serverItemsLength"
:last-page="serverLastPage"
:loading="bLocalLoading"
btn-action-path="products"
btn-action-item-key-id="id"
hide-btn-action-view
@delete="deleteItem"
>
<template v-slot:[`item.name`]="{ item }">
<name-with-avatar :name="item.name" :path="item.thumbnail" />
</template>
<template v-slot:[`item.active`]="{ item }">
<active-icon :active="item.active" />
</template>
<template v-slot:[`item.price`]="{ item }">
<v-chip label v-if="item.offers.length">
<strong class="mr-2">{{ item.offers[0].currency }}</strong>
<span>{{ item.offers[0].price }}</span>
</v-chip>
<v-chip label v-else>0</v-chip>
</template>
</data-table>
</template>
<script lang="ts">
import { Mixins, Component, Watch } from "vue-property-decorator";
import ProductMixin from "@/modules/products/mixins/Product";
import DataTable from "@bit/planetadeleste.gui.ui.data-table/index.vue";
import ActiveIcon from "@/components/common/ActiveIcon.vue";
import ProductsForm from "@/modules/products/components/Form.vue";
import NameWithAvatar from "@/components/common/NameWithAvatar.vue";
import { DataTableHeader } from "vuetify";
@Component({
components: {
DataTable,
ActiveIcon,
ProductsForm,
NameWithAvatar,
},
})
export default class ProductsList extends Mixins(ProductMixin) {
headers: DataTableHeader[] = [
{ text: "name", value: "name" },
{ text: "active", value: "active", class: "mw-150", sortable: false },
{
text: "price",
value: "price",
sortable: false,
},
{
text: "category",
value: "category_name",
},
{
text: "actions",
value: "actions",
align: "end",
sortable: false,
},
];
mounted() {
this.headers = this.$_.map(this.headers, (item) => {
item.text = this.$_.toString(this.$t(item.text));
return item;
});
this.index();
}
}
</script>

ActionButtonsTable#

Props#

Prop nameDescriptionTypeValuesDefault
item-idunion-
action-item-key-idstring-"id"
route-name-separatorstring-"."
hide-viewboolean-false
hide-updateboolean-false
hide-deleteboolean-false
is-route-nameboolean-
pathstring-
to-viewunion-
to-updateunion-
icon-viewstring-"mdi-eye"
icon-editstring-"mdi-pencil"
icon-deletestring-"mdi-delete"

Events#

Event namePropertiesDescription
delete

Slots#

NameDescriptionBindings
default

FooterTable#

Props#

Prop nameDescriptionTypeValuesDefault
totalnumber-
last-pagenumber-
valuenumber-

Events#

Event namePropertiesDescription
input