Skip to content

Commit 6c6579d

Browse files
committed
Added sorting ability to columns.
1 parent edd604b commit 6c6579d

File tree

7 files changed

+143
-21
lines changed

7 files changed

+143
-21
lines changed

README.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Vue.js Datatable Component
22

3-
Allows for quick and easy setup of filterable and paginated tables.
3+
Allows for quick and easy setup of filterable, sortable, and paginated tables.
44

55
## Installation
66

@@ -152,6 +152,18 @@ This will inject the given component into the cell for the cooresponding row. Th
152152

153153
This will align the text in both the header cells and the body cells as defined. Uses inline styles. Default: left.
154154

155+
#### sortable
156+
157+
This is a boolean value that determines whether or not that column can be sorted. Sorting is enabled by default on all columns except for component columns. Component columns do not currently support sorting. To disable sorting on any particular column, define `sortable` as `false`:
158+
159+
```
160+
{
161+
label: 'Email',
162+
field: 'email',
163+
sortable: false
164+
}
165+
```
166+
155167
### rows
156168

157169
This is the data that is represented by each row in the table. It must be an array of objects where the key of each object is the value for your column.field entries. For example, if you have a column entry like this:

dist/vuejs-datatable.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/vue-1/app.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ vm = new Vue({
1010
{label: 'Username', field: 'username'},
1111
{label: 'First Name', field: 'first_name'},
1212
{label: 'Last Name', field: 'last_name'},
13-
{label: 'Email', field: 'email', align: 'right'},
13+
{label: 'Email', field: 'email', align: 'right', sortable: false},
1414
{label: 'Address', callback: function(row){
1515
return row.address + ', ' + row.city + ', ' + row.state;
16-
}, align: 'right'}
16+
}, align: 'right', sortable: false}
1717
],
1818
rows: [
1919
{

examples/vue-2/app.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,10 @@ window.vm = new Vue({
106106
{label: 'Username', field: 'username'},
107107
{label: 'First Name', field: 'first_name'},
108108
{label: 'Last Name', field: 'last_name'},
109-
{label: 'Email', field: 'email', align: 'right'},
109+
{label: 'Email', field: 'email', align: 'right', sortable: false},
110110
{label: 'Address', callback: function(row){
111111
return row.address + ', ' + row.city + ', ' + row.state;
112-
}, align: 'right'}
112+
}, align: 'right', sortable: false}
113113
],
114114
rows: [
115115
{

0 commit comments

Comments
 (0)