Giter Club home page Giter Club logo

vue-table-component's Introduction

vue-table-component

A simple Vue component to display tables. Support sortable columns, pagination and custom css styles

Example with 2 Table components, first one with default styles and paginator, and second one with custom css styles and paginator in 'select' mode

Usage example

Demo

You can check this live demo

Usage

  <TableView
    :headers="[
      {"label":"First Name", "field":"first_name", "sortable":true, "type":"String"},
      {"label":"Email", "field":"email", "sortable":true, "type":"String"},
      {"label":"Age", "field":"age", "sortable":true, "type":"Number"}
    ]",
    :rows="[
      {"first_name":"Isidor" ,"email":"[email protected]", "age":20},
      {"first_name":"Max", "email":"[email protected]", "age":32},
      {"first_name":"Brigham", "email":"[email protected]", "age":54},
      {"first_name":"Jakob", "email":"[email protected]", "age":37},
      {"first_name":"Brannon" ,"email":"[email protected]", "age":18}
    ]",      
    :sort="{
      field: 'first_name',
      order: 'asc'
    }",
    :pagination="{
      itemsPerPage: 10,
      align: 'center',
      visualStyle: 'select'
    }",
    css-style="my-css-style"
  >
    <template v-slot:items="{ row }">
      <td>{{ row.first_name }}</td>  
      <td>{{ row.email }}</td>              
      <td>{{ row.age }}</td>            
    </template>
    <template v-slot:no-data>
      <span>No data</span>
    </template>
  </TableView>

Props

  • headers: (required) array with table columns definition (See columns definition)
  • rows: (required) array with data to fill the table
  • sort: object with sorting configuration
    • field: initial sort field
    • order: [asc/desc] sort order
  • pagination: object with pagination configuration
    • enabled: [true/false]
    • itemsPerPage: number of rows in each page
    • align: [left/center/right] position of the paginator (Default 'right')
    • visualStyle: [select/button] paginator style (Default 'button')
  • css-style: css class that will be applied to the component instead of default styles. Custom styles must be defined in this way:
<style lang="scss">
.my-css-style{
    .ozn-table {
        ...
    }
    .ozn-paginator {
        ...
    }
}
</style>

Columns definition

Each column must be defined with 4 parameters:

  • label: text that will be shown in the column header
  • field: data field related to the column
  • sortable: [true/false]
  • type: [String/Number]

vue-table-component's People

Contributors

ozoono avatar adnanlah avatar

Watchers

James Cloos 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.