0.0.8 • Published 4 years ago

buff-datatable v0.0.8

Weekly downloads
-
License
MIT
Repository
-
Last release
4 years ago

Installation

npm install buff-datatable

Individual component as Vue plugin (main.js)

import Vue from 'vue'
import { bTable } from 'buff-datatable'
import 'buefy/dist/buefy.css' // CSS File, override if custom styles will be applied

Vue.use({bTable})

API

Table

Properties

NameDescriptionTypeValuesDefault
dataTable dataArray
columnsTable columns, you can also add renderHtml: true on each column objectArray (same as TableColumns props)
default-sortSets the default sort column and order — e.g. ['first_name', 'desc']String, Arrayorder: default-sort-direction prop
default-sort-directionSets the default sort column direction on the first clickStringasc, descasc
sort-iconSets the header sorting iconString-arrow-up
sort-icon-sizeSets the size of the sorting iconStringis-small, , is-medium, is-large | is-small
borderedBorder to all cellsBooleanfalse
stripedWhether table is stripedBooleanfalse
narrowedMakes the cells narrowerBooleanfalse
selectedSet which row is selected, use the .sync modifier to make it two-way bindingObject
focusableTable can be focused and user can navigate with keyboard arrows (require selected.sync) and rows are highlighted when hoveringBooleanfalse
hoverableRows are highlighted when hoveringBooleanfalse
checkableRows can be checked (multiple), checked rows will have a .is-checked class if you want to styleBooleanfalse
checkbox-positionPosition of the checkbox (if checkable is true)Stringleft or rightleft
checked-rowsSet which rows are checked, use the .sync modifier to make it two-way bindingArray
header-checkableShow check/uncheck all checkbox in table header when checkableBooleantrue
mobile-cardsRows appears as cards on mobile (collapse rows)Booleantrue
backend-sortingColumns won't be sorted with Javascript, use with sort event to sort in your backendBooleanfalse
backend-paginationRows won't be paginated with Javascript, use with page-change event to paginate in your backendBooleanfalse
totalTotal number of table data if backend-pagination is enabledNumber0
current-pageCurrent page of table data (if paginated), use the .sync modifier to make it two-way bindingNumber1
loadingLoading stateBooleanfalse
paginatedAdds pagination to the tableBooleanfalse
pagination-simpleSimple pagination (if paginated)Booleanfalse
pagination-sizePagination size (if paginated)Stringis-small, is-medium, is-large
pagination-positionPagination position (if paginated)Stringbottom, top, bothbottom
per-pageHow many rows per page (if paginated)Number20
sort-multipleAdds multiple column sortingBooleanfalse
sort-multiple-dataUsed in combination with backend-sortingObject[{field, order}][]
sort-multiple-keyAdds a key which will be required for multi column sorting to work. Will always be enabled if null is selected (default). Requres sort-multipleStringnull, shiftKey, altKey, ctrlKeynull
row-classAdd a class to row ( element) based on the returnFunction (row: Object, index: Number)
detailedAllow row details (check scoped slots documentation)Booleanfalse
custom-detail-rowAllow a custom detail rowBooleanfalse
show-detail-iconAllow chevron icon and column to be visibleBooleantrue
opened-detailedAllow pre-defined opened details. Ideal to open details via vue-router. (A unique key is required; check detail-key prop)Array[]
has-detailed-visibleControls the visibility of the trigger that toggles the detailed rows.Function (row: Object)true
detail-keyUse a unique key of your data Object when use detailed or opened detailed. (id recommended)String
custom-is-checkedCustom method to verify if row is checked, works when is checkable. Useful for backend paginationFunction (a: Object, b: Object)
is-row-checkableCustom method to verify if a row is checkable, works when is checkable.Function (row: Object)true
is-row-selectableCustom method to verify if a row is selectable, works when is selected.Function (row: Object)true
icon-packIcon pack to useStringmdi, fa, fas, far, fad, falmdi
mobile-sort-placeholderText when nothing is selectedString
custom-row-keyUse a unique key of your data Object for each row. Useful if your data prop has dynamic indices. (id recommended)String--
draggableAllows rows to be draggableBooleanfalse
backend-filteringColumns won't be filtered with Javascript, use with searchable prop to the columns to filter in your backendBooleanfalse
sticky-headerShow a sticky table headerBooleanfalse
scrollableAdd a horizontal scrollbar when table is too wideBooleanfalse
heightTable fixed height in pixelsNumber, String
filters-eventAdd a native event to filterString
card-layoutRows appears as cards (collapse rows)Booleanfalse
aria-next-labelAccessibility label for the next page link (if paginated)String
aria-previous-labelAccessibility label for the previous page link (if paginated)String
aria-page-labelAccessibility label for the page link. If passed, this text will be prepended to the number of the page (if paginated)String
aria-current-labelAccessibility label for the current page link. If passed, this text will be prepended to the current page (if paginated)String

Slots

Slot nameDescriptionProps (if scoped)
defaultRequired, table body and headerrow: Object, index: Number
headerTable custom headercolumn: Vue Object, index: Number
subheadingTable subheadingcolumn: Vue Object, index: Number
detailRow detail (collapsible)row: Object, index: Number
emptyReplaces table body when data array prop is empty
footerTable custom footer
bottom-leftCustom bottom-left (opposite side of bottom pagination)
top-leftCustom top-left (opposite side of top pagination)

Events

NameDescriptionParameters
clickTriggers when a row is clickedrow: Object
dblclickTriggers when a row is double clickedrow: Object
sortTriggers when a sortable column is clickedfield: String, order: String
sorting-priority-removedTriggers when a multiselect sortable column remove button has been clickedfield: String
selectTriggers when a row is selectedrow: Object, oldRow: Object
checkTriggers when the checkbox in a row is clicked and/or when the header checkbox is clickedcheckedList: Array, row: Object
check-allTriggers when the header checkbox is clickedcheckedList: Array
page-changeTriggers when pagination page is changedpage: Number
details-openTriggers when details is openedrow: Object
details-closeTriggers when details is closedrow: Object
contextmenuTriggers when right-click on a rowrow: Object, contextMenuNativeEvent: Event
dragstartTriggers when starting to drag a rowrow: Object, dragEvent: Event, index: Number
dragendTriggers when ending to drag a rowrow: Object, dragEvent: Event, index: Number
dropTriggers when dropping on a rowrow: Object, drop: Event, index: Number
dragoverTriggers when dragging over a rowrow: Object, dragover: Event, index: Number
dragleaveTriggers after dragging over a rowrow: Object, dragover: Event, index: Number
mouseenterTriggers when mouse enters a rowrow: Object
mouseleaveTriggers when mouse leaves a rowrow: Object
filters-changeTriggers when filter changefilter: Object
filters-event-[filters-event]Triggers filters-event event from filter (it works only with Vue 2.6.x)event: Event, filter: Object

Methods

NameDescriptionParametersReturn
initSortSort using default-sort prop parameters
focusFocus table element if is focusable
toggleDetailsToggle row detail if table is detailedrow: Object
openDetailRowOpen row detail if table is detailedrow: Object
closeDetailRowClose row detail if table is detailedrow: Object
resetMultiSortingResets the multi column sorting

Column

Properties

NameDescriptionTypeValuesDefault
labelColumn header text, also used to identify column if custom-key prop is missingString
custom-keyUnique identifier, use when label is missing or there are duplicate label namesString, Numberthis.label
fieldProperty of the object the column is attributed, used for sortingString
metaMeta prop to add anything, useful when creating custom headersAny
widthColumn fixed width in any unit, or pixels when none is providedNumber, String
numericAlign the cell content to the right, sort icon on leftBooleanfalse
centeredAlign the cell content to the centerBooleanfalse
sortableWhether the column can be sortedBooleanfalse
visibleWhether the column is visibleBooleantrue
custom-sortCustom sort method, works when is sortableFunction (a: Object, b: Object, isAsc: Boolean)
searchableAdd a input below the header to filter dataBooleanfalse
subheadingColumn subheading textString, Number
stickyShow a sticky columnBooleanfalse
header-selectablePrevent text selection of header when setting this to false.Booleantrue
header-classCSS classes to be applied on headerString-
cell-classCSS classes to be applied on cellString-

Slots

Slot nameDescriptionProps (if scoped)
defaultRequired, table column body-
headerTable column custom headercolumn: Vue Object, index: Number
subheadingTable column custom subheadingcolumn: Vue Object, index: Number
searchableThis is to customize the search input when searchable.column: Vue Object, filters: Object

Variables

You can use these variables to customize this component.

NameDefault
$table-sticky-header-height300px
Bulma variablesLink
0.0.8

4 years ago

0.0.7

4 years ago

0.0.6

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago