A Vue Datatable Component for Vue 2.x(Vuetable)

A Vue Datatable Component for Vue 2.x(Vuetable)

Vuetable is a Vue 2.x reusable data table component that converts raw (JSON) data into HTML table format with ease and flexibility. And it should be able to work with any CSS framework because of the HTML table generated.

Vuetable is a Vue 2.x reusable data table component that converts raw (JSON) data into HTML table format with ease and flexibility. And it should be able to work with any CSS framework because of the HTML table generated.

Fields definition is a unique feature in Vuetable that allows you to define which fields to be used and manipulated before displaying.

You begin by defining data fields for your JSON data structure that you want to present in HTML table. Then, progressively configuring it to display the data the way you want.

Ultimately, you can use it to create a wrapper component to contain the UI/UX of your own datatable component in one place to achieve consistant look and feel.

Features

  • Work with data from API endpont or existing data array/object
  • Define fields to map your JSON data structure for display
  • Customize your field data display with formatter if needed
  • Advanced field customization can be done via scoped slot and field component
  • Single sort or multi-sort if your API is supported
  • Pagination components included, swappable and extensible, or write your own
  • Optional detail row to display additional data for each row
  • Adaptable to any CSS framework if it supports HTML table.
  • And a lot more!

Documentation and Tutorial

Documentation is still under development, but you can view it at https://ratiw.github.io/vuetable-2.

Meanwhile, check out

  • the Tutorial with follow-along project here. It should be enough to get you started.

  • Sample project using Vuetable-2 with Laravel 5.4 and Laravel-Mix

If you've been using Vuetable for Vue 1.x before, checkout what's changed for info on changes from Vuetable for Vue 1.x and the upgrade guide on how you could upgrade from Vuetable for Vue 1.x.

You can now make use of Vue's scoped slot using the new __slot special field. That means you are able to define action buttons per instance of a data table without depending on a globally defined component.

Use scoped slot in parent when defining the actions Vue Doc for scopped Slots

e.g.

<template slot="actions" scope="props">
    <div class="table-button-container">
        <button class="btn btn-default" @click="onClick('edit-item', props.rowData)"><i class="fa fa-edit"></i> View</button>&nbsp;&nbsp;
        <button class="btn btn-danger" @click="onClick('delete-item', props.rowData)"><i class="fa fa-remove"></i> Edit</button>&nbsp;&nbsp;
    </div>
</template>

the onClick function can now be defined in the parent and the parent has Access to rowData and rowIndex via props. :)

The original functionality still works

Breaking Changes

v1.6.0

  • The icons prop of VuetablePagination is now moved into the css prop object. See this codepen.

Example Code

  • Clone the project
  • Go into the cloned directory
  • npm install
  • npm run dev
  • Open browser to http://localhost:8080

Usage

NPM

npm install vuetable-2 --save-dev

Javascript via CDN

// vuetable-2 dependencies
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.2.6/vue.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/axios/0.16.1/axios.min.js"></script>
// vuetable-2
<script src="https://unpkg.com/[email protected]"></script>
Vue.use(Vuetable)

The .use from above will register all the components globally.

function install(Vue){
  Vue.component("vuetable", Vuetable);
  Vue.component("vuetable-pagination", VueTablePagination);
  Vue.component("vuetable-pagination-dropdown", VueTablePaginationDropDown);
  Vue.component("vuetable-pagination-info", VueTablePaginationInfo);
}

Also you have the ability to access certain components if you need them:

VueTable: VueTable.default/VueTable.VueTable,
VueTablePagination: VueTable.VueTablePagination,
VueTablePaginationInfo: VueTable.VueTablePaginationInfo,
VueTablePaginationDropdown: VueTable.VueTablePaginationDropdown

Demo

Download

vue vue-datatable vuetable

What's new in Bootstrap 5 and when Bootstrap 5 release date?

How to Build Progressive Web Apps (PWA) using Angular 9

What is new features in Javascript ES2020 ECMAScript 2020

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Random Password Generator Online

HTML Color Picker online | HEX Color Picker | RGB Color Picker

10 Best Vue Icon Component For Your Vue.js App

In this article, I will collect 10 Vue icon component to bring more interactivity, better UI design to your Vue application.

7 Best Vue Highlight Component for Your Vue App

Vue highlight is often used to highlight text and syntax. Here are the 7 Vue highlight components I've collected.

Top 15 Vue Datatable Components

Vue DataTable components help to show data from different sources. In other words, you can call them a feature-complete grid-like component.

Collection of 10 Vue Markdown Component for Vue.js App in 2020

Markdown is a way to style text on the web. The 10 Vue markdown components below will give you a clear view.

Collection of 15 Vue Input Component for Your Vue.js App

Vue input component gives you a baseline to create your own custom inputs. It consists of a prepend/append slot, messages, and a default slot. In this article I will share 15 Vue input components to you.