Vue table component with virtual dom and easy api.

Overview

vue-virtual-table

npm version downloads

Vue table component with virtual dom and easy api.

  • Keep smooth when the data reachs thousands of rows or even more.
  • Easy to use with a simple config.

live demo

Installation

yarn add vue-virtual-table

or

npm install --save vue-virtual-table

Usage

A simplest example:

<template>
  <vue-virtual-table :config="tableConfig" :data="tableData"> vue-virtual-table>
template>

<script>
  import VueVirtualTable from 'vue-virtual-table'
  export default {
    components: {
      VueVirtualTable
    },
    data: () => ({
      tableConfig: [{ prop: 'user' }, { prop: 'age' }],
      tableData: [{ user: 'a1', age: 20 }, { user: 'a2', age: 21 }, { user: 'a3', age: 23 }]
    })
  }
script>

Every item of the config refers to a column. When you don't set sepcific 'name' of the table column header, it will uses the 'prop' value as default. Or you can set the tableConfig like:

tableConfig: [{ prop: 'user', name: 'User Name' }, { prop: 'age', name: 'Age' }]

And if you want to search in the 'user' column, set the tableConfig like:

tableConfig: [{ prop: 'user', name: 'User Name', searchable: true }, { prop: 'age', name: 'Age' }]

For the 'age' column which is a set of number, you'd better use 'numberFilter' to filter numbers with "<", ">", "between" etc.

tableConfig: [{ prop: 'user', name: 'User Name', searchable: true }, { prop: 'age', name: 'Age', numberFilter: true }]

There are many convenient features hard to explain one by one. Here is a complex example and you can get more info in the tables below the example:

<template>
  <vue-virtual-table
    :config="tableConfig"
    :data="tableData"
    :height="800"
    :itemHeight="55"
    :minWidth="1000"
    :selectable="true"
    :enableExport="true"
    v-on:changeSelection="handleSelectionChange"
  >
    <template slot-scope="scope" slot="actionCommon">
      <button @click="edit(scope.index, scope.row)">Editbutton>
      <button @click="del(scope.index, scope.row)">Deletebutton>
    template>
  vue-virtual-table>
template>

<script>
  import VueVirtualTable from 'vue-virtual-table'
  export default {
    components: {
      VueVirtualTable
    },
    data: () => ({
      tableConfig: [
        { prop: '_index', name: '#', width: 80 },
        {
          prop: 'user',
          name: 'User',
          searchable: true,
          sortable: true,
          summary: 'COUNT'
        },
        { prop: 'age', name: 'Age', numberFilter: true },
        { prop: 'city', name: 'City', filterable: true },
        { prop: '_action', name: 'Action', actionName: 'actionCommon' }
      ],
      tableData: [
        { user: 'a1', age: 20, city: 'aaaa' },
        { user: 'a2', age: 21, city: 'bbbb' },
        { user: 'a3', age: 23, city: 'aaaa' }
      ]
    }),
    methods: {
      handleSelectionChange(rows) {
        console.log(rows)
      },
      edit(index, row) {
        console.log(index)
      },
      del(index, row) {
        console.log(index)
      }
    }
  }
script>

Examples

Click here to see the examples. You can clone this repo and use vue serve example/xxx.vue to preview.

Table Attributes

name type description required default
data Array The array of data. Every item is a row. Yes
config Array The config of table. Yes
minWidth Number Set the minimum width of table. No 1200px
height Number Set the height of table. No 300px
itemHeight Number Set the height of row. No 42px
bordered Boolean Whether table has vertical border. No false
hoverHighlight Boolean Whether to hightlight current row. No true
selectable Boolean Whether row is selectable. No false
enableExport Boolean Whether to show export-to-table button No false
language String Language from ['en', 'cn'] No 'cn'

Table Events

name parameters description
changeSelection rows When the selected rows change
click row, $event When row is clicked
contextmenu row, $event When row is right-clicked

Table Config

param type description required default
prop String Property name Yes
name String Display name No same to the property name
width Number Column width No auto
sortable Boolean Whether this column is sortable No false
searchable Boolean Whether this column is searchable No false
filterable Boolean Whether this column is filterable No false
numberFilter Boolean If it's a column of number. You can use this. No false
summary String summary type from ['COUNT', 'SUM'] or customize(eg. ${clicks}*100/${reach} is calculated with the summary of other two columns). No
prefix String Display before the value No
suffix String Display after the value No
alignItems String Same with flex. Control the content of a cell No center
isHidden Boolean Whether this column is hidden No false
eTip Array Tool tip of a cell to display certain props (eg. ['name'] will display the value of 'name' prop in the tool tip ) No
eTipWithProp Boolean Whether to show the prop name in the tool tip No
eClass Object Attach class to the cell (eg. {redColor: '${spend}>100'} add the 'redColor' class to the cell whose 'spend' prop is greater than 100) No No

Special Props

name description
_index Show the index of row
_action A slot to customize the content
_expand A slot to customize a popover window
Comments
  • Pass template instead of property value

    Pass template instead of property value

    Now I can render in the column only prop value.

    It will be great if I can render my template for each prop, e.g.:

    <template>
      <vue-virtual-table
        :config="tableConfig"
        :data="tableData"
      >
        <template slot-scope="scope" slot="user-info">
          <div>{{scope.info}}</div>
        </template>
    
        <template slot-scope="scope" slot="age-info">
          <div>{{scope.info}}</div>
        </template>
      </vue-virtual-table>
    </template>
    
    <script>
    import VueVirtualTable from 'vue-virtual-table'
    export default {
      components: {
        VueVirtualTable
      },
      data: {
        tableConfig: [
          {prop: 'name', name: 'Name'},
          {prop: 'age', name: 'Age', slotName: 'age-info'},
          {prop: 'info', name: 'Info', slotName: 'user-info'}
        ],
        tableData: [
          {user: 'a1', age: 20},
          {user: 'a2', age: 21},
          {user: 'a3', age: 23}
        ]
      }
    }
    </script>
    

    Thanks! @waningflow

    opened by davydof 5
  • add support for justify-content

    add support for justify-content

    Hi, I noticed that align items is meant for vertical align and it would be great if we can set horizontal align css style using justify content option.

    I tested and if you don't mind, I'll make a PR for this change Document would be as below and UI would be

    param | type | description | required | default -- | -- | -- | -- | -- alignItems | String | Same with flex. Control the content of a cell | No | center justifyContent | String | Defines how the browser distributes space between and around content items. | No | center

    before image

    after (set age : justify-content left)

    image

    opened by Chaho12 3
  • Added support for nested properties #11

    Added support for nested properties #11

    Found my self needing support for nested properties so here is the code if you are interested.

    Added method getDescendantProp(obj, path).
    The method getDescendantProp is applied were applicable in vue-virtual-table.vue.

    Executed build
    Bumped package version

    Example method usage:

    // Access user.name
    this.getDescendantProp({user: {name: "userName", age: 43}},  "user.name")
    >> userName
    // Access user.age
    this.getDescendantProp({user: {name: "userName", age: 43}},  "user.age")
    >> 43
    
    opened by nockstarr 3
  • Popover Window does not shows up

    Popover Window does not shows up

    Hi There

    First I'd like to say thank you for your very impressive component vue-virtual-table.

    I'm about to build a big project under VueCLI and your component is just perfect.

    Nonetheless I got one major issue. When I set in the configuration table "filterable" or "searchable" then the popover window do not shows up.. In real it shows up but very fast and close right after...

    Then I can't use that properties which is really helpful.

    Could you please help me out ?

    Thank you

    opened by WebPlanning 3
  • Row click events?

    Row click events?

    How would I go about handling LEFT and RIGHT click events on a row? Don't seem like 'click' or 'contextmenu' events are fired. Need access to row data when left or right clicking.

    opened by nockstarr 2
  • How to use in browser without module bundlers

    How to use in browser without module bundlers

    Hi.

    I have tried everything to try and get this to work in the browser.

    I have a Vue which is receiving a lot of data. I would ideally like to pass this directly to vue-virtual-table as a prop.

    I have tried integrating with https://github.com/FranckFreiburger/http-vue-loader

    my main.js

    var app = new Vue({
        el: '#app',
        components: {
            // 'VueVirtualTable': window.httpVueLoader('./tableComponent.vue')
            'my-component': httpVueLoader('https://raw.githubusercontent.com/waningflow/vue-virtual-table/master/src/vue-virtual-table.vue')
        },
        data: {
            table_data: "",
            column_names: [{ prop: "first" }, { prop: "id" }, { prop: "last" }, { prop: "city" }]
        },
    

    my index.html header

        <script defer src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
        <script defer src="https://unpkg.com/http-vue-loader"></script>
        <script defer src="vue-virtual-table.min.js"></script> <!-- downloaded from this github -->
        <script defer src="vueScript.js"></script>
    

    Any help getting this working would be immensely appreciated.

    opened by brendanfalk 2
  •  Get nested properties

    Get nested properties

    Thanks so much for wonderful component.

    How can I access the nested properties of an object? { prop: 'nested properties here', name: 'HOST', searchable: true },

    json_prop

    Is it possible to reflect several properties from an array in one column?

    Thanks in advance!

    opened by optical-genius 1
  • #15 - Add 'click' and 'contextmenu' events to clicked row

    #15 - Add 'click' and 'contextmenu' events to clicked row

    Added click and contextmenu events when a row is left/right clicked. Both events emits props.item and $event.

    Docs updated. Executed build script (only build) and is therefor pushing new dist files.

    opened by nockstarr 0
  • Tooltip on custom slot

    Tooltip on custom slot

    Is it possible to config a tooltip for custom slot columns? At the moment I use custom css (override with text-overflow: ellipsis) for too long text in columns so I want to display the full text in the tooltip. Or: Is there a way to config a static column/cell with line break?

    Thanks in advance.

    opened by sangermann 0
  • date formatting & sorting

    date formatting & sorting

    Hi, thank you very much for your great work - this vue component truely rocks! Is there a way to use a date column with formatted cell display (without template slot-scope) so that it is still sortable?

    opened by sangermann 5
  • Miltiple _actions prop eClass not working

    Miltiple _actions prop eClass not working

    When appliying eClass to multiple _action slot components takes the class name of the last _action prop

    tableConfig: [ { prop: "_action", name: ".", actionName: "checkbox", width: 30, eClass: { checkbox: 'true' }}, { prop: "_action", name: "Name", actionName: "userBlock", width: 180}, { prop: "emailAddress", name: "Email Address", width: 180 , alignItems: "left"}, { prop: "phoneNumber", name: "Phone Number" }, { prop: "company", name: "Company" }, { prop: "address", name: "Address" }, { prop: "_action", name: ".", width: 70, actionName: "actionCommon"}, ],

    All the _action blocks takes the Class checkbox

    opened by harshadsatra 0
Owner
Jack Woods
Do something interesting.
Jack Woods
vue3-easy-data-table is a simple and easy-to-use data table component made with Vue.js 3.x

Introduction vue3-easy-data-table is a simple and easy-to-use data table component made with Vue.js 3.x. The data table component in Vuetify 3 hasn't

HC 222 Dec 30, 2022
Arne De Smedt 122 Dec 26, 2022
A fully functional Vue Table, to meet most of the Table all requirements, and perfect compatibility with any component library

s-table A fully functional Vue Table, to meet most of the Table all requirements, and perfect compatibility with any component library.

杨玉杰(Chris Yang) 0 Jun 26, 2020
A simple table component based Vue 2.x: https://dwqs.github.io/v2-table/

中文 README v2-table A simple table component based Vue 2.x. Installation Install the pkg with npm: npm i --save v2-table beautify-scrollbar or yarn ya

Pomy 98 Feb 7, 2022
BeeGridTable , is a Highly Customizable Table UI component library based on Vue.js. Rich functions、More efficient、Easy to use!

BeeGridTable (中文) Description BeeGridTable , is a Highly Customizable Table UI component library based on Vue.js. Rich functions、More efficient、Easy t

刘佳恒 45 Oct 31, 2022
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.

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.

null 29 Sep 16, 2022
An easy to use, clean and powerful data table for VueJS with essential features like sorting, column filtering, pagination

Vue-good-table An easy to use, clean and powerful data table for VueJS with essential features like sorting, column filtering, pagination and much mor

Obaid Samadian 0 May 13, 2019
Powerful virtual data grid smartsheet with advanced customization

Powerful virtual data grid smartsheet with advanced customization. Best features from excel plus incredible performance ??

null 0 May 30, 2021
An easy to use powerful data table for vuejs with advanced customizations including sorting, column filtering, pagination, grouping etc

Vue-good-table An easy to use, clean and powerful data table for VueJS with essential features like sorting, column filtering, pagination and much mor

null 2k Jan 2, 2023
Lightweight and flexible table component for the web :zap:

Teible Lightweight and flexible table component for the web. No more hassle writing columns outside the template or customizing render template. Packa

Hiển Đào Vinh 56 Dec 9, 2022
Lightweight and flexible table component for the web.

Teible Lightweight and flexible table component for the web. No more hassle writing columns outside the template or customizing render template. Packa

Hiển Đào Vinh 56 Dec 9, 2022
A simple, customizable and pageable table with SSR support, based on vue2 and element-ui

Documentation Full Doc Online Demo for front-end pagination Online Demo for server-end pagination Dev install dependencies yarn install serve test/pl

Leon Zhang 1k Dec 30, 2022
data table simplify! -- datatable component for Vue 2.x. See documentation at

Vuetable-2 - data table simplify! Vuetable-2 v2.0-beta is available now! See the next branch. Vuetable-2 works with Vue 2.x, vuetable is for Vue 1.x I

Rati Wannapanop 2.2k Jan 4, 2023
Yeap, another Vue table component.

Vue Data Tablee Yeap, another Vue table component. This one is based on vue-good-table, a simple and pretty table component. Install Install from npm.

Vitor Luiz Cavalcanti 40 Mar 2, 2021
A vue component for pivot table

vue-pivot-table A vue component for pivot table Live demo (jsfiddle) Install npm install --save @marketconnect/vue-pivot-table Components This project

Click2Buy 213 Dec 19, 2022
A table (with tree-grid) component for Vue.js 2.0. (Its style extends @iView)

A table (with tree-grid) component for Vue.js 2.0. (Its style extends @iView)

Gao Qi(高琦) 861 Dec 19, 2022
a ant-desgin-vue table component

a ant-desgin-vue table component

null 4 Feb 17, 2022
Customizable Vue Table Component

prot-table Description A customizable table component in vue. Intended to be used as a web-component or as a component in vue projects. demo jsfiddle

Protronic GmbH 4 Feb 14, 2020
vue table component of vue2

vue-virtual-table Vue table component with virtual dom and easy api. Keep smooth when the data reachs thousands of rows or even more. Easy to use with

Jack Woods 93 Dec 27, 2022