Vuetable Properties
api-mode
type:
Booleandefault:
trueusage:
By default, Vuetable will request the data from an API endpoint specified in
api-url.However, you can instruct Vuetable to use your existing data instead by setting
api-modetofalse(also known as "Data mode"). Then, Vuetable will look for the data in thedataprop.The data you supply to
dataprop must be of the JSON structure that Vuetable can work with. Please see [JSON Data Structure] for more detail.Please note that disabling
api-mode(by setting it tofalse) will also disable all API related functionalities, like sorting, filtering, etc. But you can usedata-managerprop to define the data manager function that can perform those functionalities to the data before Vuetable is using it.Note
Setting
api-modetofalseis not recommended. It will not scale well when you have to handle a large dataset yourself instead of letting database manager at the backend handles it for you.See also:
- JSON Data Format
data-managerproptransformprop
api-url
works in API mode only
type:
Stringdefault:
''(empty string)usage:
The URL of the api endpoint that Vuetable will interact with.
If the API supports sorting, filtering, pagination of the data, Vuetable can automatically append appropriate information to the server via query string.
Note
Vuetable does not do sort or know how to sort your data. It is just a presentation layer of your data returned from the server side (API endpoint).
In API mode, your API endpoint must be able to accept sort options; otherwise, the sorting will not work. Vuetable can send appropriate request with sort option when the user interacts with it. See [Sorting] for more detail.
In Data mode, you, as a developer, are responsible for sorting the data using any mechanism of your choice and then supply that sorted data to Vuetable to display.
See also:
append-params
works in API mode only
type:
Objectdefault:
{}(empty object)usage:
Additional parameters that Vuetable should append to the query string when requesting data from the server.
See also:
- [TODO]: Appending Other Parameters to the Query String
css
type:
Objectdefault:
{}(empty object)usage:
This is where you should override the CSS classes that Vuetable uses to render HTML table that should help you style the table to your needs.
See also:
data
works in Data mode only
type:
Array|Objectdefault:
nullusage:
The data that Vuetable will be used to render the table when
api-modeis set tofalse.WARNING
You can utilize the pagination functionality of Vuetable if the
datayou supplied is an object that has data structure as described in Data Format.
data-manager
works in Data mode only
type:
Functiondefault:
nullusage:
See explanation here.
data-path
works in API mode only
type:
Stringdefault:
datausage:
The path inside the data structure that contains actual the data.
TIP
If the data is at the root of the structure, set this prop to empty string, e.g.
data-path="".
detail-row-component
type:
Stringdefault:
''(empty string)usage:
A component name to be used as the content of detail row to be displayed underneath the current row.
detail-row-transition
type:
Stringdefault:
''(empty string)usage:
The CSS class to apply to detail row during transition.
detail-row-class
type:
Stringdefault:
vuetable-detail-rowusage:
The CSS class to apply to the detail row.
detail-row-options
type:
Objectdefault:
{}(empty object)usage:
Object to be passed to the detail row component as
optionsprop.
event-prefix
fields
type:
Arraydefault:none
required: true
usage:
Array of field definition that Vuetable will be used to map to the data structure in order to render the table for presentation.
See also:
field-prefix
type:
Stringdefault:"vuetable-field-"
usage::
Default component name prefix of the Feild component used in Vuetable.
The
__characters in field name of field definition serve as a shorthand for Field component to be used for the given column. The shorthand will be replaced with the given prefix during initialization of Vuetable.See also:
first-page
works in API mode only
type:
Numberdefault:
1usage:
First page number. Set this prop to 0 for zero based pagination.
If the first page of your API endpoint is
0, you can use this prop to set it.
header-rows
type:
Arraydefault:['VuetableRowHeader']
usage:
Array of row header components to be rendered as table header.
See also
http-fetch
works in API mode only
type:
Functiondefault:
nullusage:
Allow specifying external HTTP request function to fetch the data via AJAX.
If
null, Vuetable will fallback to usingaxiosinternally.If specified, Vuetable will call the given function passing
apiUrland already constructedhttpOptionsto the function.WARNING
Vuetable would expect the given function to make an AJAX call to the
apiUrlwith thehttpOptionsand return a Promise. Vuetable would then handle the success or failure of the AJAX call after the Promise has been resolved.See
loadDataandfetchmethods inVuetable.vuesource code if you're confused.Here's an example using
vue-resource//... myFetch(apiUrl, httpOptions) { return Vue.$http.get(apiUrl, httpOptions) }, //...
http-method
works in API mode only
type:
Stringdefault:
getusage:
Only support
getorpostmethod. Please note that it must be the lowercase string.
http-options
works in API mode only
type:
Objectdefault:
{}(empty object)usage:
Allow passing additional options to the server during AJAX call. Internally, Vuetable uses
axiosto handle AJAX request.
initial-page
works in API mode only
type:
Numberdefault:
1usage:
The initial page number of data to be requested the first time Vuetable is loaded.
load-on-start
works in API mode only
type:
Booleandefault:
truerequired: true
usage:
Whether Vuetable should immediately load the data from the server after finish initialization.
min-rows
type:
Numberdefault:
0usage:
The minimum number of rows that should be displayed when rendering the table.
If the number of row available is less than the number specified in
min-rowsprop, Vuetable will render empty table rows to satisfy that minimum rows.
multi-sort
works in API mode only
type:
Booleandefault:
falseusage:
Enable multiple sort columns interaction.
When this is enabled, user can press a modifier key (specified in
multi-sort-keyprop) to do subsequent sorting of the sort result.Note
In multi-sort mode, the sort icon in subsequent sort column will appear dimmer to indicate the level of sorting.
multi-sort-key
works in API mode only
type:
Stringdefault:
altpossible values:
alt,ctrl,shift,metausage:
The key to trigger column adding/subtracting when multi-sort is enabled.
per-page
works in API mode only
type:
Numberdefault:
10usage:
The number of data to be requested per page.
query-params
works in API mode only
type: [
Object, _Function`]default:
{ sort: 'sort', page: 'page', perPage: 'per_page' }usage:
The text to be used as keys in query string that will be sent to the server. If your API endpoint uses different keys, you can specified them via this prop.
When you set
query-paramsprop as a _Function, you can completely override the behevior ofquery-prams` prop on how the query string is constructed.Vuetable will pass the following parameters to the given function:
sortOrder-- the current sort ordercurrentPage-- the current display pageperPage-- the current page size
The function must return an object containing key-value pair(s) to be constructed as query string; otherwise, and empty object
{}will be returned instead.See also:
reactive-api-url
works in API mode only
type:
Booleandefault:
trueusage:
This tells Vuetable whether it should watch for the change in
api-urlprop and refresh the data automatically.
row-class
type:
String,Functiondefault:
''(empty string)usage:
The CSS class name that will be applied to each table row.
If
row-classprop is a _Function`, Vuetable will automatically call the given function on each row, passing the row data and row index to it. Vuetable will then use the returned string from the given method as CSS class for that row.Here is the example on using a method to return the row class for styling.
<template> <vuetable> :row-class="onRowClass" ></vuetable> </template> <script> //.. methods: { onRowClass (dataItem, index) { return (dataItem.isOverdue) ? 'color-red' : 'color-white' } } </script>
show-sort-icons
type:
Booleandefault:
trueusage:
This tells Vuetable whether or not icons should be added to
thelements whenever a given column is sortable.
sort-order
works in API mode only
type:
Arraydefault:
[](empty array)usage:
The default sort order that Vuetable should use when requesting the data from server.
sort-params
works in API mode only
type:
Functionthat returnsStringdefault:
nullusage:
If assigned, this function will be called by Vuetable passing the current sort orders array as a parameter. You can use it to override how the sort parameters are constructed as part of the query string that will be sent to the API endpoint.
The function must return a string to be included in the query string of API request.
no-data-template
type:
Stringdefault:
''(empty string)usage:
Text to be displayed when there are no records in the table. It also support HTML.
The text will be inserted into a
tdwhich is spaned the whole row.
pagination-path
works in API mode only
type:
Stringdefault:
links.paginationusage:
The pagination path inside the data structure that contains the pagination information.
If the your data from the server does not have pagination metadata, you should set the prop to empty string, e.g.
pagination-path="", to suppress warning from Vuetable.
table-height
type:
Stringdefault:
nullusage:
Fix the height of table body.
When set, the height of the body of Vuetable will be set at the given value and vertical scrollbar will appear automatically when the content of table body is longer than the given value.
The value can be any unit valid in HTML.
WARNING
You must also set the width of each column in fields definition when you specify the height of table, otherwise, the width of the each column in the header and in the body will not look the same.
Because Vuetable renders table header and table body as separate tables.
track-by
type:
Stringdefault:
idusage:
The key that uses to unqiuely identified each row in the data array to help track the state of detail row and checkbox features of Vuetable. This is necessary for the detail row and checkbox features to function correctly.
For detail row, whenever the user clicks to expand the detail row, Vuetable will insert the
idof that row into its internal array (visibleDetailRows). And when that detail row is hidden, theidof that detail row is removed from the array.For checkbox, when the user selects (checked) a row, Vuetable will insert the
idof the row into its internal array (selectedTo). And when that row is unselected (unchecked), theidof that row is removed from the array.See also:
transform
works in API mode only
type:
Functiondefault:
nullusage:
A function that allows the user to programmatically transform the receiving data into the one can Vuetable can works with.
When defined, the given function will be called whenever Vuetable recieves the requested data from the server, before the data are displayed. This provides a hook to manipulate the data that developer might have control over its format, transforming the data into the format that Vuetable can be used.
The function will receive the raw data returned from the server as its parameter. It must returns the already transformed data; otherwise, the table might appear as empty.
See also: