Coder Social home page Coder Social logo

terp / vuejs-datatable Goto Github PK

View Code? Open in Web Editor NEW

This project forked from gerkindev/vuejs-datatable

0.0 1.0 0.0 3.25 MB

A Vue.js component for filterable and paginated tables.

Home Page: https://gerkindev.github.io/vuejs-datatable/

License: MIT License

TypeScript 38.60% JavaScript 36.05% Vue 13.96% CSS 0.99% HTML 10.39%

vuejs-datatable's Introduction

vuejs-datatable

A VueJS plugin to manage data tables

Allows for quick and easy setup of filterable, sortable, and paginated tables. Currently supports Vue.js ^2.4.

npm npm version Renovate Known Vulnerabilities Build Status Maintainability Test Coverage GitHub commit activity the past year license

E2E testing over Travis realized using

๐Ÿ‘‰ Browse the documentation ๐Ÿ“š


Getting started

Install the package

To install this package, simply install vuejs-datatable with your favorite package manager:

# Using npm
npm install vuejs-datatable
# Using yarn
yarn add vuejs-datatable

Import the package

Use the ESM build

The ESM build (EcmaScript Module) implies that you target browsers that support ESM OR you use a bundler, like webpack, rollup.js or Parcel.

Import & register the DatatableFactory in Vue:

import Vue from 'vue';
import DatatableFactory from 'vuejs-datatable';

Vue.use(DatatableFactory);

Check out how to customize table types to see some usage of the DatatableFactory.

Use the IIFE build

The IIFE build (Immediately Invoked Function Expression) should be prefered only for small applications without bundlers, or if you privilegiate the use of a CDN

In your HTML, load the IIFE build directly, if possible right before the closing </body> tag. You must make sure that the loading order is preserved, like below.

<body>
    <!-- All your page content... -->
    <script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.4.2/vue.js" defer></script>
    <script src="/dist/vuejs-datatable.js" defer></script>
    <script src="/myscript.js" defer></script>
</body>

The IIFE build exposes the DatatableFactory as the global VuejsDatatable. Check out how to customize table types to see some usage of the DatatableFactory.

Use the component

Use the component in your HTML or template:

<div id="vue-root">
    <datatable :columns="columns" :data="rows"></datatable>
</div>

Then pass in the columns and the data to your Vue instance:

new Vue({
    el: '#vue-root',
    data: {
        columns: [
            {label: 'id', field: 'id'},
            {label: 'Username', field: 'user.username', headerClass: 'class-in-header second-class'},
            {label: 'First Name', field: 'user.first_name'},
            {label: 'Last Name', field: 'user.last_name'},
            {label: 'Email', field: 'user.email'},
            {label: 'address', representedAs: ({address, city, state}) => `${address}<br />${city}, ${row.state}`, interpolate: true}
        ],
        rows: [
            //...
            {
                "id": 1,
                "user": {
                    "username": "dprice0",
                    "first_name": "Daniel",
                    "last_name": "Price",
                    "email": "[email protected]"
                },
                "address": "3 Toban Park",
                "city": "Pocatello",
                "state": "Idaho"
            }
            //...
        ]
    }
});

Customize the datatable

The DatatableFactory exposes several methods to allow you to add or modify other datatable-like components, with custom styles or behavior.

VuejsDatatable
    .registerTableType( 'my-awesome-table', tableType => {
        tableType
            .mergeSettings( /* ... */ )
            .setFilterHandler( /* ... */ )
            .setSortHandler( /* ... */ );
    } );

Documentation

Browse the full documentation at https://gerkindev.github.io/vuejs-datatable/.

Attributions

vuejs-datatable's People

Contributors

pstephan1187 avatar renovate-bot avatar jannishuebl avatar eblanshey avatar jankal avatar casperlaitw avatar oleksiibrylin avatar tobiasartz avatar

Watchers

Nate Terpstra avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.