Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
vue3-easy-data-table
Advanced tools
vue3-easy-data-table is a simple and easy-to-use data table component made with Vue.js 3.x.
I am doing the Vue2 to Vue3 migration for the project of my company recently, In the Vue2 version, we were using the data table component of Vuetify2. But for the new Vue3 version, Vuetify3 Beta seems not ready for the production environment yet, and the data table component in Vuetify3 is still in development, so I made vue3-easy-data-table by referring to the API and UI of the data table component in Vuetify2. If you are also waiting for the release of the data table component of Vuetify3, what about trying this component first?
npm install vue3-easy-data-table
// or
yarn add vue3-easy-data-table
import Vue3EasyDataTable from 'vue3-easy-data-table';
import 'vue3-easy-data-table/dist/style.css';
const app = createApp(App);
app.component('EasyDataTable', Vue3EasyDataTable);
<template>
<EasyDataTable
:headers="headers"
:items="items"
/>
</template>
<script lang="ts">
import type { Header, Item } from "vue3-easy-data-table";
export default defineComponent({
setup() {
const headers: Header[] = [
{ text: "Name", value: "name" },
{ text: "Height (cm)", value: "height", sortable: true },
{ text: "Weight (kg)", value: "weight", sortable: true },
{ text: "Age", value: "age", sortable: true }
];
const items: Item[] = [
{ "name": "Curry", "height": 178, "weight": 77, "age": 20 },
{ "name": "James", "height": 180, "weight": 75, "age": 21 },
{ "name": "Jordan", "height": 181, "weight": 73, "age": 22 }
];
return {
headers,
items
};
},
});
</script>
vue3-easy-data-table has two modes: client-side
mode and server-side
mode. Client-side mode is for the case that all data has already been loaded, In other words, your initial call is asking for all the pages from a server. And In server-side mode, you need to request limited data from a server everytime you navigate to a new page. Client-side mode is the default mode, you have to pass server-options
and server-items-length
props to switch to the server-side mode.
You can customize only certain columns like this:
<EasyDataTable :headers="headers" :items="items">
<template #email="{ email }">
<a :href="email">{{ email }}</a>
</template>
</EasyDataTable>
Notice that the <name>
of #<name>
should be a value of header item.
Use buttons-pagination
prop and seven visible page buttons will be generated automatically to help you navigate much easier.
Use dense
prop to provide an alternate dense style.
Using the v-model:items-selected
will enable you to get data of specific items by toggling checkbox.
Add sortable
property into the header items to make the corresponding columns sortable.
const headers: Header[] = [
{ text: "Height", value: "height", sortable: true },
...
];
Use sort-by
and sort-type
to define the initial sorting field and sorting type ('asc' or 'desc').
Use search-field
and search-value
props to search for information in a specific field. If you don't pass the search-field
prop, the component will search in all fields.
notice: Searching feature is only available in client-side mode.
Also called server-side mode, In this mode, you’re loading data already paginated and sorted from server. You should watch the serverOptions
to know when to request new pages from server. Don't forget to use the loading
prop to display a loading bar while fetching data.
server-items-length
and v-model:server-options
are required in this mode.
Use theme-color
prop to customize color of checkbox, active option of rows selector, loading bar and active button of buttons pagination.
common props can be used both in client-side mode and server-side mode.
Name | Required | Type | Default | Description |
---|---|---|---|---|
v-model: itemsSelected | false | Item[] (Record<string, any>[]) | null | Items selected |
alternating | false | boolean | false | Set true to color alternating (even and odd) rows. |
body-font-color | false | string | '#212121' | Font color of table body |
body-font-size | false | number | 12 | Font size of table body, including foot pagination |
border-color | false | string | '#e0e0e0' | Border color |
buttons-pagination | false | boolean | false | By default, you can only use prev and next buttons to navigate. But if you set the value to true, Seven visible page buttons will be generated automatically to help you navigate much easier |
dense | false | boolean | false | Set true to decrease the height of rows |
empty-message | false | string | 'No Available Data' | Message to display when there is no data in table |
fixed-header | false | boolean | true | Fixed header to top of table. NOTE: Does not work in IE11 |
headers | true | Header[] Header: { text: string, value: string, sortable?: boolean, } | [] | Table header items |
header-background-color | false | string | '#fff' | Background color of table head |
header-font-color | false | string | '#373737' | Font color of table head |
items | true | Item[] (Item: Record<string, any>) | [] | Table body items |
loading | false | boolean | false | If true and no items are provided, then a loading bar and loading message will be shown |
loading-message | false | string | 'Loading, please wait.' | Message shown when loading is true and no items are provided |
max-height | false | number | null | null | Max height of table (table header and table body, not including footer pagination) |
rows-hover-color | false | string | '#eee' | Background color of row when mouse hover |
rows-items | false | number[] | [25, 50, 100] | A number array of rows-per-page, working as the options of rows per page selector |
rows-per-page | false | number | 25 | Rows of items to display in per page |
show-index | false | boolean | false | Set true to show index of item. |
theme-color | false | string | '#42b883' | Fill color of checkbox, background color of active option of rows selector, color of loading bar and background color of active button of buttons pagination |
Name | Required | Type | Default | Description |
---|---|---|---|---|
search-field | false | string | '' | A specific field in which you search for information. (the value of search field should be a value of header item, not text of header item). If you don't pass a specific field, the component will search in all fields. |
search-value | false | string | '' | Search value |
sort-by | false | string | '' | A specific field for sorting |
sort-type | false | 'asc' | 'desc' | 'asc' | Order by 'asc' or 'desc' when sorting |
Name | Required | Type | Default | Description |
---|---|---|---|---|
v-model:server-options | true | ServerOptions: { page?: number, rowsPerPage?: number, sortBy?: string, sortType?: 'asc' | 'desc', } | {} | An object which can be used as values of parameters in a pagination REST API such as:http://localhost:8080/api?page=${ServerOptions.page}&limit=${ServerOptions.rowsPerPage}&sortBy=${ServerOptions.sortBy}&sortType=${ServerOptions.sortType} |
server-items-length | true | number | undefined | Total amount of items available on server |
Add alternating
prop to color alternating (even and odd) rows.
Add show-index
prop to show index of item.
If you find any bug or demand any other features, plese report an issue and making pull requests is very welcomed!
FAQs
A customizable and easy-to-use data table component made with Vue.js 3.x.
The npm package vue3-easy-data-table receives a total of 15,433 weekly downloads. As such, vue3-easy-data-table popularity was classified as popular.
We found that vue3-easy-data-table demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.