-
Notifications
You must be signed in to change notification settings - Fork 298
Fields Definition
Fields can be defined as simple string array, array of object, or the mix.
-
Fields defined as simple array
var columns = ['name', 'email', 'birthdate', 'gender']
-
Fields defined as array of object
var columns = [ { name: 'name', sortField: 'name' }, { name: 'email', title: 'Email Address' }, { name: 'birthdate', sortField: 'birthdate', titleClass: 'center aligned', dataClass: 'center aligned', callback: 'formatDate|D/MM/Y' }, { name: 'gender', sortField: 'gender', titleClass: 'center aligned', dataClass: 'center aligned', callback: 'gender' }, ]
-
Fields defined as array of the mix
var columns = [ 'name', 'email', { name: 'birthdate', sortField: 'birthdate', titleClass: 'center aligned', dataClass: 'center aligned', callback: 'formatDate|D/MM/Y' }, { name: 'gender', sortField: 'gender', titleClass: 'center aligned', dataClass: 'center aligned', callback: 'gender' }, //... ]
The difference is that if you defined a field as simple.
vuetablewill only display it as is without sorting or transforming options.vuetablewill convert the simple field definition to field object with onlynameproperty.var columns = ['name'] // will be converted to this // var columns = [ { name: 'name' } ]
-
nameName of the data field to be display.
-
sortFieldUsually, it will be the same as
nameoption. But you can specify different value if you use different field name when querying data on the serve side, e.g. firstname.If specified, the field will be marked as sortable.
vuetablewill display appropriate clickable icon after the field title.vuetablewill also make a new request to the server with thesort=<sortField>query string appended. -
titleIf you would like to specify the title yourself, you can put it in here. Otherwise,
vuetablewill use thenameoption instead. -
titleClassThe css class you would like to apply for the title of this field.
-
dataClassThe css class you would like to apply for the data of this field.
-
callbackThe name of the callback function to be called to allow any transformation of the value to be displayed. See Callback section for more info.
-
visibleWhether this field should be visible or hidden when rendering the table.
If the JSON data structure contains nested objects, eg:
{
"links": {
"pagination": {
"per_page": 15,
}
},
"data": [
{
"id": 1,
"name": "xxxxxxxxx",
"email": "xxx@xxx.xxx",
"group_id": 1,
"address" {
"street_address":"123 abc place",
"city":"townsville",
"province":"Harbor",
"country":"Antegria"
}
}
.
.
.
{
"id": 50,
"name": "xxxxxxxxx",
"email": "xxx@xxx.xxx",
"group_id": 3,
"address" {
"street_address":"456 xyz street",
"city":"cityville",
"province":"Portia",
"country":"Norland"
}
}
]
}In this case, the column names of nested objects can be specified in the following format:
var columns = ['name', 'email', 'address.city', 'address.country']- Properties
- Fields Definition
- Special Field
- Callbacks
- Detail Row
- Events
- Data Format (JSON)
- Sorting, Paging, and Page Sizing of Data
- Appending Other Parameters to the Query String
- Sample Data Using Laravel
- Customize the Pagination Info
- Pagination Components
- CSS Styling
- Using vuetable with Twitter's Bootstrap
- Displaying a Loading Animation
- Extending vuetable Pagination Component