0.1.39 • Published 10 months ago

@supertab/supertab-beta v0.1.39

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

Supertab

This repository contains Vue component which provides additional features for tabulator regarding filtering, sorting, UI etc.

Description:

Component provides additional step in column filtering, filter operation can be selected (eg. contains, greater or equal etc.). It provides columns layout and selected filters saving to local storage (last selected filters and columns layout are saved automatically). Multi-column sort and columns toggling are also supported.

Column customization

Supertab reads column configuration from headerFilterParams column property.

Column optionShort descriptionValue typeAvailable values
columnTypeColumn value typeint1 (TEXT), 2 (NUMERIC), 3 (SELECT), 4 (DATETIME), 5 (BOOLEAN)
defaultFilterDefault filter type which will be pre-selectedstringstartsWith, greaterOrEqual, lowerOrEqual, eq, neq, contains, notContains, endsWith, included, notIn
isRangeEnable filter by rangebooleanfalse is default
valuesOption is used to show available options in case column is filtered by SELECT optionarray[]{text: 'Option 1', value: 1}

Package installation:

npm install @supertab/supertab-beta

Configuration

Plugin initialization

Initialize supertab plugin in main.js

import SupertabPlugin from '@supertab/supertab-beta'

Vue.use(SupertabPlugin, {
  locale: 'sr'
 })

NOTE: Currently supported english (en) and serbian (sr) plugin localization.

One-time auth configuration

If getting data for table requeires authorization, configure methods for retrieving refresh and access token, setting access token and refresh token API endpoint.

Vue.use(SupertabPlugin,
  {
    locale: 'sr',
    refreshTokenUrl: 'http://localhost:8080/api/example/token/refresh',
    getRefreshToken: getRefreshToken,
    getAccessToken: getAccessToken,
    setAccessToken: setAccessToken,
    isValidUser: isUserActive
  }
)

Supertab component configuration

Configuration which can be passed to Supertab component as props is listed bellow:

PropShort descriptionTypeRequeired
refAccess component through refsstringYes
refNameRepresents name of component ref. Same value like ref attributestringYes
supertabKeyUnique table keystringYes
dataData for tableArrayYes
optionsTable configurationObjectYes
layoutsArray of predefined layouts and filtersArrayNo
<Supertab ref='tabulator' refName='tabulator' supertabKey='localTabulator' v-bind:data="data" v-bind:options="tabulatorOptions" class="tabulator-root" ></Supertab>

Basic example:

Tabulator options example:

tabulatorOptions: {
    layout: 'fitColumns',
    responsiveLayout: true,
    pagination: 'local',
    resizableColumns: 'header',
    layoutColumnsOnNewData: true,
    ajaxFiltering: false,
    ajaxSorting: false,
    paginationSizeSelector: [10, 25, 50],
    paginationSize: 10,
    columns: [
        {
            title: 'Name',
            field: 'name',
            headerSort: true,
            headerFilterParams: {
                columnType: ColumnFilterType.TEXT,
                defaultFilter: 'contains'
            },
            hozAlign: 'left',
            cssClass: 'multi-line-cell'
        },
        {
            title: 'Change in % (last 24h)',
            field: 'percent_change_24h',
            headerSort: true,
            hozAlign: 'left',
            headerFilterParams: {
                columnType: ColumnFilterType.NUMERIC,
                defaultFilter: 'greaterOrEqual'
            },
            visible: false
        },
        {
            title: 'Category',
            field: 'category',
            headerSort: true,
            hozAlign: 'left',
            formatter: (cell, formatterPatern, renderer) => {
                if (cell.getValue() === 1) {
                    return 'Category One'
                }
                if (cell.getValue() === 2) {
                    return 'Category Two'
                }
                if (cell.getValue() === 3) {
                    return 'Category Three'
                }
                return 'Category Unknown'
            },
            headerFilterParams: {
                columnType: ColumnFilterType.SELECT,
                values:
                [
                    {
                        text: 'Category 1',
                        value: 1
                    },
                    {
                        text: 'Category 2',
                        value: 2
                    },
                    {
                        text: 'Category 3',
                        value: 3
                    }
                ]
            },
            visible: false
        }
    ]
}

NOTE: Attribute supertabKey must be unique per application due it is used to store tabulator filters, layouts and sorts by this key.

Predefined filters and layouts: Multiple predefined filters and layouts can be defined through the configuration. Predefined filters and layouts should be passed as attribute value to Supertab component (:layouts attribute). JSON contains 2 arrays under filter and layout name with keys columns and filters. Under columns, put array which represents tabulator columns configuration with main properties (field, title, headerSort, hozAlign, visible). Under filters, put array of objects with following properties: field, title, inputFilterType, inputFilterValue. inputFilterType uses value from one of available filter codes startsWith, greaterOrEqual, lowerOrEqual, eq, neq, contains, notContains, endsWith, included, notIn.

Example of predefined filters and layout:

{
'Layout/filter name': {
    columns: [
        {
            field: 'id',
            title: 'Id',
            headerSort: true,
            hozAlign: 'left',
            visible: true
        },
        {
            field: 'name',
            title: 'Name',
            headerSort: true,
            hozAlign: 'left',
            visible: true
        },
        {
            field: 'category',
            title: 'Category',
            headerSort: true,
            hozAlign: 'left',
            visible: false
        }
    ],
    filters: [
        {
            title: 'Name',
            field: 'name',
            inputFilterType: 'notContains',
            inputFilterValue: 'coin'
        },
        {
            title: 'Category',
            field: 'category',
            inputFilterType: 'included',
            inputFilterValue: [
                1,
                2
            ]
        }
    ]
},
'Another filter': {
    columns: [],
    filters: [
        {
            title: 'Name',
            field: 'name',
            inputFilterType: 'contains',
            inputFilterValue: 'coin'
        },
        {
            title: 'Category',
            field: 'category',
            inputFilterType: 'included',
            inputFilterValue: [
                2
            ]
        }
    ]
}

Initial filters: To setup initial filters for each column set initialFilters property inside headerFilterParams property. initialFilters value should be type of Object, where property names are names of filter operations and values of those properties are filter values.

Example columns options with initial filters:

tabulatorOptions: {
    layout: 'fitColumns',
    responsiveLayout: true,
    pagination: 'local',
    resizableColumns: 'header',
    layoutColumnsOnNewData: true,
    ajaxFiltering: false,
    ajaxSorting: false,
    paginationSizeSelector: [10, 25, 50],
    paginationSize: 10,
    columns: [
        {
            title: 'Id',
            field: 'id',
            headerSort: true,
            headerFilterParams: {
              columnType: ColumnFilterType.NUMERIC,
              defaultFilter: 'contains',
              initialFilters: {
                included: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
              }
            },
            hozAlign: 'left'
        },
        {
            title: 'Name',
            field: 'name',
            headerSort: true,
            headerFilterParams: {
              columnType: ColumnFilterType.TEXT,
              defaultFilter: 'contains',
              initialFilters: {
                contains: 'coin'
              }
            },
            hozAlign: 'left',
            cssClass: 'multi-line-cell'
        }
    ]
}

Filters format sent to backend: | Operation | Query string format | | ------ | ------ | | Greater or equal | columnName=gte.filterValue | | Lower or equal | columnName=lte.filterValue | | Equal | columnName=eq.filterValue | | Not equal | columnName=neq.filterValue | | Contains | columnName=cs.filterValue | | Not contains | columnName=ncs.filterValue | | Ends with | columnName=enw.filterValue | | Starts with | columnName=stw.filterValue | | Included | columnName=in.(filterValue1, filterValue2, ...) | | Not Included | columnName=nin.(filterValue1, filterValue2, ...) |

More resources:

NPM package page

Scripts

Examples (screenshots)

0.1.39

10 months ago

0.1.38

10 months ago

0.1.35

11 months ago

0.1.36

11 months ago

0.1.37

11 months ago

0.1.31

1 year ago

0.1.32

1 year ago

0.1.33

1 year ago

0.1.34

1 year ago

0.1.30

2 years ago

0.1.27

2 years ago

0.1.28

2 years ago

0.1.29

2 years ago

0.1.24

2 years ago

0.1.25

2 years ago

0.1.26

2 years ago

0.1.20

2 years ago

0.1.21

2 years ago

0.1.22

2 years ago

0.1.23

2 years ago

0.1.17

2 years ago

0.1.18

2 years ago

0.1.19

2 years ago

0.1.16

2 years ago

0.1.15

2 years ago

0.1.10

2 years ago

0.1.11

2 years ago

0.1.12

2 years ago

0.1.13

2 years ago

0.1.14

2 years ago

0.1.9

2 years ago

0.1.8

2 years ago

0.1.7

2 years ago

0.1.6

3 years ago

0.1.5

3 years ago

0.1.4

3 years ago

0.1.3

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago