Home

Awesome

<img alt="vue-quintable" src="https://sensetence.com/vue-quintable-demo/vue-table.png" width="265" height="222">
:warning: VueQuintable version 2.x is for bootstrap 5.x. If you want to use bootstrap 4.x please install latest 1.x VueQuintable version:warning:
:exclamation: The @sensetence/vue-quintable module is the successor of @quintet/vue-quintable. Please note that future development and bug fixes will be provided in the @sensetence/vue-quintable module only. :exclamation:

VueQuintable

VueQuintable is a table wrapper for Vue.js 2.x. It is build with bootstrap 5.x. High configurable, easy to use, flexible and responsive.

Demo

Getting Started

These instructions will get you running VueQuintable for your project for development purposes.

Prerequisites

VueQuintable is a vue.js package and uses bootstrap by default. Please install both before using the package. If you want to use ajax functionalities please install axios as it is used by VueQuintable.

npm:

npm install --save axios

yarn:

yarn add axios

Installing

npm:

npm install --save bootstrap
npm install --save @popperjs/core
npm install --save @sensetence/vue-quintable

yarn:

yarn add bootstrap
yarn add @popperjs/core
yarn add @sensetence/vue-quintable

Integration

import Vue from 'vue'

//use bootstrap
import 'bootstrap/dist/css/bootstrap.css'

import "@sensetence/vue-quintable/dist/vue-quintable.css"
import VueTable from '@sensetence/vue-quintable'
Vue.use(VueTable);

Use directly in browser

You can either install VueQuintable via bower

bower install --save https://github.com/sensetence/vue-quintable

or just download the source and include the scripts and styles in dist folder to use VueQuintable for your browser page.

<script type="text/javascript" src="/path/to/vue/dist/vue.min.js"></script>

<script type="text/javascript" src="/path/to/project/dist/vue-quintable.umd.min.js"></script>

<link rel="stylesheet" href="/path/to/project/dist/vue-quintable.css"></link>
Vue.use(window["vue-quintable"]);

Features

These points will convince you that VueQuintable is the last table plugin you will ever need

Slots

You can define some slots to customize the table as you want to.

<template v-slot:header>Your HTML-Code</template>

//for content of regular table cells
<template v-slot:cell-content="{cell}">
    <button v-if="cell.any_property ==='any_value'" class="cell-content-button">
        {{cell.any_property}}
    </button>
</template>

//for content of responsive generated table cells
<template v-slot:generated-cell-content="{cell}">
    <button v-if="cell.any_property ==='any_value'" class="generated-cell-content--button">
        {{cell.any_property}}
    </button>
</template>

//for content of sticky table cells
<template v-slot:sticky-cell-content="{cell}">
    <button v-if="cell.any_property ==='any_value'" class="sticky-cell-content-button">
        {{cell.any_property}}
    </button>
</template>

//for same content of regular, responsive generated and sticky table cells
<template v-for="slotName in ['cell-content','generated-cell-content','sticky-cell-content']" #[slotName]="{cell}">
    <button v-if="cell.any_property ==='any_value'" :key="`button-${slotName}`" :class="`${slotName}`-cell-button">
        {{cell.any_property}}
    </button>
</template>

Events

Add listeners for the following events to handle them as you want to.

Configuration

The following will give you an overview how to configure the VueQuintable for your needs.

Table Properties

ParameterTypeRequiredDescription
configObjectyesThe table configuration object. See details below.
rowsArrayyes (if no ajax url is set)Table rows containing all cells. See details below.
preSelectedRowsArraynoArray of objects{key,value} to set selection of rows from outside. You have to set the key to an unique property of the row e.g. an id and the value to the actual properties' value of the row. If done so, the row will be (pre-) selected. Note: This won't work initially, for initial select use config.defaultSelected or row.selected properties
dynamicConfigBooleannoIf set to true the Table wont be re-initialized and re-rendered if some values inside the config property are changed. This is useful to dynamically set config values for columns
filtersObjectnoThe active filters for displaying rows. This has to be an object with filter name as key and filter value as value. Additionally a set of operators can be passed. See example below.
filter-groupsArraynoFilter groups with relations. See example below.
sort-orderObjectnoSet sorting values and order by default or on the fly. See examples below.
axiosObjectnoPass a configured axios instance to be used for ajax functionalities. Only relevant if ajax is used. Recommendation: set it to the current time using new Date() for update
updatedBoolean|DatenoProperty to trigger reload on current page. Only relevant if ajax is used.
verboseBooleannoDefault is false. Set to true to see debug informations on developer tools in your Browser.
identifierStringnoDefault is null, for nested tables default is a random string. Use for slots of nested tables
initialSearchTermStringnoDefault is null, initial search term if search is enabled
nestedBooleannoDefault is false, use it if a quintable is nested inside a slot

Property config properties

KeyTypeRequiredPre-conditionDescriptionDefaultExample
columnsArrayyes-Contains the configuration for the table columns including headlines.nullSee below
hideEmptyColumnsBooleanno-If set to true columns of visible rows which are empty for each row will be hidden. Will check text, html, component propertiesfalsetrue
ignoreSortEmptyColumnsString{"none"|"active"|"all"}nohideEmptyColumns enabledSelect if/how columns with sort enabled shall be hidden if they are empty for each row. "none": sorting columns keep always visible. "active": sorting columns will always keep visible if they are active. "all": empty sorting columns will be hidden as well"none""all"
expandedAllBooleannoBreakpoints for columns are setIf set to true, all columns will be expanded by defaultfalsetrue
enableRowTabIndexBooleanno-If set to true, an active row will be set on click and can be navigated by arrow keysfalsetrue
hoverClassBoolean|Stringno-Class for rows on hover"bg-muted""bg-success"
activeClassBoolean|Stringno-Class for active row"bg-muted""bg-success"
hideRowToggleBooleannoBreakpoints for columns are setIf set to true, no plus symbols will be displayed for row toggle.falsetrue
expandedRowIconStringnoBreakpoints for columns are setToggle icon for expanded rows. Possible values: "chevron-up", "minus", "caret-up", "eye-slash""chevron-up""minus"
collapsedRowIconStringnoBreakpoints for columns are setToggle icon for collapsed rows. Possible values: "chevron-down", "minus", "caret-down", "eye""chevron-down""plus"
paginationBoolean|Numberno-If set to true, the default page size will be 25.false5
numberOfVisibleRowsFillerWordStringnopagination is setFiller word for numbers of visible rows displaying, especially needed for translation (no english tables)"of""von"
pageRangeNumbernopagination enabledDisplayed page range of pagination.53
rowsSelectBooleannopagination enabledIf set to true, user will be allowed to set rows per pagefalsetrue
disallowAllOptionBooleannopagination enabled and rows select is enabledIf set to true, "all" option will not be displayed in rows per page selectfalsetrue
rowsPlaceholderStringnopagination enabled and rows select is enabledText for rows per page selection"Rows per page:""Rows:"
selectBooleanno-If set to true rows can be selected by check boxes. Tables v-model can be used for selected row Array.falsetrue
prettySelectBooleannoselect is enabledIf set to true, pretty checkboxes library will be used.falsetrue
selectPositionString{"pre"|"post"}noselect is enabledPosition of the select check boxes, first or last column."post""pre"
selectAllBooleannoselect is enabledIf set to true, additional checkbox will appear to select all rowsfalsetrue
selectAllRowsBooleannoselect is enabledIf set to true, select all selects all rows allover the pages. Please keep in mind that this won't work with server side pagination.falsetrue
defaultSelectedBooleannoselect is enabledIf set to true, all rows will be selected initially.falsetrue
searchBooleanno-If set to true a filter search input will be displayedfalsetrue
searchLengthNumbernosearch is enabledMinimum length of query that triggers search.13
searchPlaceholderStringnosearch is enabledPlaceholder if no search query is entered"Search...""Search rows..."
searchContainerClassStringnosearch is enabledCSS class for search container"row""container-class"
searchClassStringnosearch is enabledCSS class for search input wrapper"col-12""col-md-8"
emptyPlaceholderStringnosearch is enabled or filters are setPlaceholder if filtering rows has no results."No rows""No results"
filterRelationString{"OR"|"AND"}nofilters are setFilter relation, if no filter group affected"AND""OR"
filterGroupRelationString{"OR"|"AND"}nofilters are setDefault relation filter groups to each other"AND""OR"
multiSortBooleannosort is enabled on at least one columnIf set to true multi-key sorting is enabledfalsetrue
multiSortSelectBooleannosort is enabled on at least one columnIf set to true user will be allowed to enable and disable multi sortfalsetrue
multiSortPlaceholderStringnosort is enabled on at least one column and multi sort select is enabledPlaceholder for multiple sort description"Multiple sort""Toggle multiple"
pageSortBooleannosort is enabled on at least one columnIf set to true sorting on current page enabledfalsetrue
pageSortSelectBooleannosort is enabled on at least one columnIf set to true user will be allowed to enable and disable page sortfalsetrue
pageSortPlaceholderStringnosort is enabled on at least one column and page sort select is enabledPlaceholder for page sort description"Page sort""Toggle page"
ajaxUrlString|Booleanno-If set ajax will be used for search/filter/sort/paginationfalse"http://your.server.url/api/endpoint"
requestMethodString{"GET"|"POST"}noajaxUrl is setRequest method for ajax request"GET""POST"
storeStateBooleannoidentifier is setStore table state in local storage to have persistent table when reload pagefalsetrue
ajaxRequestDelayIntegernoajaxUrl is setDelay for ajax search requests in milliseconds250100
Property columns for property config properties
KeyTypeOptions/ReturnPre-conditionDescription
headlineString--Headline for column
titleString--Description, displayed on hover the headline
classesString--Space separated css classes string. Will be applied for headlines, cells, generated rows and sticky rows.
hiddenBooleantrue|false-If set to true the column will not be displayed in any case. Highly recommended to use only when dynamicConfig is set to to true.
ignoreEmptyBooleantrue|falseconfig property hideEmptyColumns enabledThe column will never be hidden automatically due to emptiness
sortBooleantrue|false-If set to true, this column will be sortable
firstSortDirectionString"ASC"|"DESC"sort is setIndicates the first direction of sorting when sort is activated for a column by clicking on the sort header. Default: "ASC"
breakpointString"xs"|"sm"|"md"|"lg"|"xl"|"xxl"|"all"-Bootstrap breakpoint from which descending the columns headline will be shown
showHeadlineBreakpointString"xs"|"sm"|"md"|"lg"|"xl"|"xxl"|"all"headline is setBootstrap breakpoint from which descending the columns headline will be shown
hideHeadlineBreakpointString"xs"|"sm"|"md"|"lg"|"xl"|"xxl"|"all"headline is setBootstrap breakpoint from which descending the columns headline will be hidden
alignString"start"|"end"|"center"-Text alignment for whole column
alwaysExpandedBooleantrue|falsebreakpoint is setIf set to true, the additional columns row will be always expanded if the breakpoint is reached
stickyBooleantrue|falsebreakpoint is not setIf set to true, this column will be always displayed as additional row and will be expanded always
cellFormatterFunctionString|Object-Function for complex custom cell formatting. The cell will be passed as function parameter. Has to return a string handled as text or an object with String value and String type{"html","text"}

Property rows properties

KeyTypePre-conditionDescriptionDefault
cellsArray-List of cells for the rownull
selectedBooleanselect is enabledIf set to true the row will be selected on defaultfalse
disableSelectBooleanselect is enabledIf set to true this row will be excluded from selection at allfalse
expandedBooleanbreakpoint of at least one column is affectedIf set to true the row will be expanded on defaultfalse
keywordsString[]search is enabledAdditional keywords which will match a search querynull
classesString-Additional CSS classes for rownull
filtersObjectfilters are setFilters with filter name(s) and value(s), which will match selected filter(s)null
alignString{"start"|"end"|"center"}-Text alignment for whole row, this will be overwritten by columns align value"start"
Property cells for property rows properties
KeyTypePre-conditionDescription
textStringnon of the following are set: html, componentContent string
htmlStringnon of the following are set: text, componentHTML content string
componentStringnon of the following are set: text, htmlCustom component object, see code example below. Should not be used, use slot cell-content instead
classesString-Additional CSS classes for cell
alignString-Text alignment for whole column, this will overwrite columns and rows align values
isEmptyBooleannon of the following are set: text, html, componentFlag for custom cells (e.g for slot generation). This is checked for hiding empty cells and the flag will overwrite potential content of text and html if set to true
sortValueString|Numbersort is enabled for the column of the cellcell value for the sorting of the column, especially useful if the sorting is enabled for formatted or html/component

Lets have a look on an example for rows and cells

//Table with columns "Name","Age","Birth Place","Job"

[
    //simple row as array
    [ 
        {
            text:"John Doe"
        },
        {
            text:50
        },
        {
            text:"Trainee"
        },
    ],
    //advances row as object
    {
    	cells:[
            {
                html:"<b>Max</b> Mustermann",
                classes:"special-td",
                align:"end",
             },
            {
                component:{
                    name:"age-component",
                    props:{
                        age:20,
                    }
                },
            },
            {
                text:"Trainee"
            },
		]
    }
]


Component Definition

To use a custom component inside a VueQuintable you have to define it as the following:

<template>
    <div @click="check">
      Age: {{age}}
    </div>
</template>


<script>

    export default {
        props:["age"],
        methods: {
            check() {
                //emit the pre-defined event for component actions
                //handled from VueQuintable by "component:event"
                this.$emit("action",
                    {
                        age:this.age,
                    }
                )
            }
        }
    }

</script>

Import and use the Component in your Code:

import TestComponent from "./components/TestComponent.vue"

Vue.component(
    "test-component",
    TestComponent.default || TestComponent
);

Property filters properties

KeyTypeRequiredDescription
valuesMixed|ArrayYesCompare values. Can be single value or array of values which will match the filter values of rows.
operatorStringNoOperator for comparing. The defined operators are:<br />equal, greater, less, greaterEqual, lessEqual, startsWith, endsWith, contains, notContains, matches
compareFunctionNoCustom compare function. See Below.

This example shows selected values for active, printable, first_name, middle_name, and last_name filters. Operators can be:

{
   active:true,
   printable:false,
   first_name:
    {
        operator:"contains",
        values:["Jo","ja"],   
    },
    middle_name:
    {
        compare:"matches",
        values:new RegExp("r.+a","g"),   
    },
    last_name:
    {
        compare:(value,rowValue)=>{
        	return rowValue.indexOf(value) === 2;
        },
        values:"a",   
    }
   
}

Property filter-groups properties

KeyTypeDescription
itemsObject[]List that contains Object of filter names or nested groups related to the group
relationString{"OR"|"AND"}Relation between the items

This filter groups example will cause to show rows that have filter matching filter values for selected name OR active filter AND selected printable filter. This groups are infinitely nestable.

[
    {
        items:[
            {
                items:[
                    {
                        name:"name"
                    },
                    {
                        name:"active"
                    }
                ],
                relation:"OR",
            },
            {
                items:[
                    {
                        name:"printable"
                    }
                ],
            }
        ],
        relation:"AND"
    }
],

Property sort-order properties

These examples depict a sorting ordered second column (index=1) before first column (index=0). You can use Objects to set the ascending or descending order optionally. The Default will be asc=true, column index starts on zero.

//simple
[
   1,0
]

//advanced
[
    {
        index:1,
        asc:false
    },
    {
        index:0,
        asc:true
    },
]

Basic Example

A simple basic example to show the usage of VueQuintable. More examples are included in the project and can be started with:

npm run start
<template>
	<VueQuintable :config="config" :rows="rows"></VueQuintable>
</template>

<script>

    import VueQuintable from './components/VueQuintable.vue

    ...
 
  	data() {
        return {
            config: {
                columns: [
                    {
                        headline: "Name",
                    }, {
                        headline: "Age",
                    }, {
                        headline: "Birth Place",
                        breakpoint: "md"
                    }, {
                        headline: "Job",
                        sticky: true,
                    }
                ],
            },

            rows: [
                [
                    {
                        text: "Mia Wong"
                    },
                    {
                        text: 50
                    },
                    {
                        text: "Beijing"
                    },
                    {
                        text: "Trainee"
                    },
                ],
                [
                    {
                        text: "Peter Stanbridge"
                    },
                    {
                        text: 18
                    },
                    {
                        text: "London"
                    },
                    {
                        text: "Trainee"
                    },
                ],
                [
                    {
                        text: "Natalie Lee-Walsh"
                    },
                    {
                        text: 25
                    },
                    {
                        text: "Dublin"
                    },
                    {
                        text: "Trainee"
                    },
                ],
            ],
        }
    }
          
  ...
</script>

AJAX data example

<template>

...

<VueQuintable :loading="loading" :config="remoteConfig" :rows="remoteRows" />

...

</template>

<script>
	import axios from 'axios'

	...

  	data(){
        return {
            loading:false,
            remoteConfig:null,
            remoteRows:null
  		
 	...
 
    mounted(){
        this.loading = true;
        axios.get("http://your.server.url/api/endpoint").then((response)=>{
            this.remoteRows = response.data.rows;
            this.remoteConfig = response.data.config;
            this.loading = false;
        });
    }
...

</script>

The request for the ajax handling on server has got the following structure:

{
    //String search query
    search:"some query",
    //Object Filters, see above
    filters:{},
    //Number etries per page
    perPage:12,
    //Number current page, starting at 1
    page:2,
    //Object sorting columns and 
    sort:{
        //Array of sorting column indexes
        indexes:this.currentSortIndexes,
        //Object of column definitions keyed by column index
        columns:this.sortingColumns,
    },
};

The response has to be the following structure:

{
	//Array of all rows, structure see above
	rows:[]
    //Number of all matching rows, without paging
    all:240
}

Good to know

License

VueQuintable is free for everyone to use in any project (MIT License).

Authors

Sensetence UG - Samuel Zeitler