1.8.1 • Published 2 months ago

@uniquedj95/vtable v1.8.1

Weekly downloads
-
License
MIT
Repository
-
Last release
2 months ago

vTable

An advanced Data table for Ionic Vue framework.

Example Table

Installation

npm install @uniquedj95/vtable

OR

yarn add @uniquedj95/vtable

Usage

Register datatable globally

// src/main.ts
import { VTable } from "@uniquedj95/vtable"

// import datatable css
import '@uniquedj95/vtable/dist/lib/datatable.css'

const app = createApp(App)
  .use(IonicVue)
  .use(VTable)
  .use(router)

router.isReady().then(() => {
  app.mount('#app');
});
// Example.vue
<template>
  <data-table :rows="rows" :columns="columns"></data-table>
</template>

Register datatable locally

<script lang="ts">
  import { DataTable } from "@uniquedj95/vtable"
  import { defineComponent } from "vue"

  export default defineComponent({
    data: () => ({
      rows: [],
      columns: []
    })
    components: {
      DataTable
    }
  })
</script>

<template>
  <data-table :rows="rows" :columns="columns"></data-table>
</template>

Note: that you need to manually import styles from @uniquedj95/vtable/dist/lib/datatable.css

API Reference

1. Props

Prop NameDefault ValueDescription
rows List of data that is mapped into table rows
asyncRowsundefinedA promise function that return list of data
columns List of table columns definitions
actionButtons list of buttons that are used to perform global table actions
rowActionButtons list of buttons that are used to perform actions that affect a specific row
customFilters list of custom filters that affects the source of data
colorundefinedcolor themes that is applied to the datatable. The following are accepted colors: primary" | "secondary" | "tertiary" | "success" | "warning" | "danger" | "light" | "dark" | "medium" | "custom"
configundefinedconfiguration that affects how the datatable functions

1.1 Table Column

A table column has the following proprties

Property NameRequiredDescription
labelYesThe string on the table column headings e.g. First Name
pathYesThe path that is used to map rows and columns e.g. first_name
exportableNoSpecifies if values on that column can be exported to external files such as CSV. The default value is true
initialSortNoSpecifies if the column be used for initial data sorting. Default value is false
sortableNoSpecifies if the column can be used for sorting data at anytime. Default value is true
initialSortOrderNoSpecifies the initial sort order for this column. This works only when the initialSort is set to true. The following are acceptable orders: "asc" | "desc" | "none"
sortCaseSensitiveNoSpecifies if the comparison for values in that column is case sensitive when sorting. The default value is false
drillableNoSpecifies if the column data can be drilled. A drillable column must receive an array value which is passed to the onDrilldown function handler. The array length value is used to display on the drillable columns. the default value is false
preSortNoA function that takes each column value and return processed value that is used when sorting
formatterNoA function that takes column values and return formated values that are displayed on the table

1.2 Action Button

These are top buttons whose actions affects the whole table. An Action Button has the following properties

Property NameRequiredTypeDescription
labelYesStringused as button label e.g submit
iconNoioniconsRendered together with the label separated by |
colorNoStringSpecifies the color of the button. Default is primary
actionYesfunctionA listener function to button clicks. It receives activeRows, allRows, filters and columns

1.3 Row Action Button

These are buttons that are attached to each row for specific row actions. The button has the following properties

Property NameRequiredTypeDescription
labelNostringused as button label. If both label and icon are not defined, "Button" will be used as a button label
iconNoioniconAn ionicon string that is used as a button label. If both label and icon are defined, icon will be used
colorNoStringSpecifies the color of the button. Default is primary
defaultNoBooleanSpecifies if the button listens to the whole row clicks. default is false
conditionNoFunctionA function that returns boolean which is used to determine whether to show or hide the button. Default is () => true
actionYesFunctionA listener function to button clicks. It receives row data and its index

1.4 Custom Filter

The are filters that are used when fetching data from the source/API. A custom filter has the following properties

Property NameRequiredTypeDescription
idYesStringA unique id used to identify the filter
labelNoStringA filter input label
valueNoanyDefault value parsed to the filter
gridSizeNoNumberSpecifies the column grid size of the filter. It accepts numbers between 1 and 12
typeYesStringSpecifies the type of the filter input field. Accepted values are : "text" | "number" | "date" | "select" | "dateRange"
optionsNoArrayList of options required for select input filters
placeholderNoStringA placeholder string used on the filter when no value is set
requiredNoBooleanSpecifies if the filter is required to be set before before emitting filter events
multipleNoBooleanRequires type to be set to select. Specifies whether to select multiple items or not
onUpdateNoFunctionA callback function that is called whenever filter value changes
slotNameNoStringused in defining named slots for advanced filters

1.4.1 Filter Option

A filter option is an object that has the following properties

Property NameRequiredTypeDescription
labelYesStringA label that is rendered on the screen
valueYesString | NumberThe value of the option
isChekedNoBooleanSpecifies whether the option is selected. Mostly used with checkboxes, or radio buttons.
otherNoanyAny other data that needs to be passed as part of the option

1.5 Table Config

These are general configuration that affects how the datatable functions. The config has the following properties

Property nameRequiredtypeDefaultDescription
showSubmitButtonNoBooleanfalseSpecifies whether to show/hide the submit buttom for custom filters. When enabled, filter changes does not immediately emit filter events till the submit button is pressed.
showSearchFieldNoBooleantrueSpecifies whether to show or hide the search input field. When disabled, the search field will be completely hidden even when the data is available
showIndicesNoBooleanfalseSpecifies whether to show index numbers column

2. Events

The following events are emitted by the data table

Event NameDescription
customFilterEmitted when submit button is clicked and all the required filters are set. If showSubmitButton is false, the event is emitted whenever a filter changes
drilldownEmitted when a drillable cell is clicked

Examples

Contribution

1.8.1

2 months ago

1.8.0

3 months ago

1.8.0-alpha

3 months ago

1.8.0-beta.1

3 months ago

1.8.0-beta.3

3 months ago

1.8.0-beta.2

3 months ago

1.8.0-beta

3 months ago

1.7.2

5 months ago

1.7.1

6 months ago

1.7.0

6 months ago

1.5.1

8 months ago

1.5.0

8 months ago

1.5.1-beta.1

8 months ago

1.5.1-beta.2

8 months ago

1.5.0-beta.2

8 months ago

1.5.0-beta.1

8 months ago

1.5.0-beta.8

8 months ago

1.5.0-beta.5

8 months ago

1.5.1-beta

8 months ago

1.5.0-alpha

8 months ago

1.5.0-0

8 months ago

1.5.0-beta

8 months ago

1.4.3

1 year ago

1.4.2

1 year ago

1.4.1

1 year ago

1.4.0

1 year ago

1.3.0

1 year ago

1.2.5-2

1 year ago

1.2.5-1

1 year ago

1.2.5-4

1 year ago

1.2.5-3

1 year ago

1.2.4

1 year ago

1.2.3

1 year ago

1.2.2

1 year ago

1.2.1

1 year ago

1.2.0

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6-0

2 years ago

1.0.5

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago