Socket
Book a DemoInstallSign in
Socket

@warlord0/vuetablebase

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@warlord0/vuetablebase

Vuetable-2 with Bootstrap 4

0.1.1
latest
Source
npmnpm
Version published
Maintainers
1
Created
Source

Vuetable-2 Components Roll Up

This component uses the excellent vuetable-2 as a base to build on top of and deliver a componentised instance using search, pagination and field definitions.

A single component building an overall Bootstrap 4 styled table with props that determine what data is shown. To get the best from it you'll need to include it in a project with Bootstrap 4 and Fontawesome.

Screenshot

screenshot

Usage Example

<template>
  <div id="table">
    <vuetable-base
      :fields-def="fields"
      :per-page="15"
      :sort-order="sortOrder"
      api-url="/admin/users"
      @row-clicked="onRowClicked"
    />
  </div>
</template>

<script>
import VuetableBase from 'VuetableBase'

import fieldsDef from 'fieldsDef'

export default {
  data () {
    return {
      fields: fieldsDef, // Field Definitions / rendering
      sortOrder: [{
        field: 'name',
        direction: 'asc'
      }]
    },
    methods: {
      onRowClicked (rowData) {
        // Magic happened
      }
    }
  }
}
</script>

Example fieldsDef with Mixin

import UsersFields from './usersFields.vue'

export default [
  /* Don't need to see the checkbox or id  */
  // '__checkbox',
  // { title: 'ID', name: 'id', sortField: 'id' },
  { title: 'User&nbsp;Name', name: 'username', sortField: 'username',
    titleClass: 'w-20'},
  { title: 'Name', name: 'name', sortField: 'name',
    titleClass: 'w-20' },
  { title: 'Email', name: 'email',
    titleClass: 'w-15' },
  {
    title: 'Custom Column',
    name: UsersFields,
    titleClass: 'w-65'
  }
]

usersFields.vue

<template>
  <th
    v-if="isHeader"
    v-html="title"
  />
  <td v-else>
    {{ rowData }} <!-- Do something here -->
  </td>
</template>
<script>
import VuetableFieldMixin from 'vuetable-2/src/components/VuetableFieldMixin.vue'

export default {
  name: 'Userfields',
  mixins: [VuetableFieldMixin]
}
</script>

Properties

PropTypeDescription
api-urlStringURL for axios to call for getting data
fields-defObjectvuetable-2 field definition
per-pageNumberNumber of rows per page for pagination
row-clickedFunctionCallback to execute when a row is clicked
sort-orderArrayField to sort by and direction eg. [{ field: 'name', direction: 'asc' }]

Keywords

vue

FAQs

Package last updated on 03 Aug 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.