Skip to content

Commit

Permalink
allow for setting default order by schema
Browse files Browse the repository at this point in the history
  • Loading branch information
noogen committed Nov 26, 2018
1 parent 1c66f0a commit 70ca7fa
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 9 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ fields: {
- `defaultContent` provide default html when no data available
- `render` custom cell rendering function https://datatables.net/reference/option/columns.render
- `template` simple vue template for the field. See example App.
- `defaultOrder` null, asc/desc - the default/initial sort order

> It is important to understand why one should use `fields` and not `opts.columns`. Though, `fields` is optional, you can simply pass `opts.columns` definition if you do not wish to use `fields`.
Expand Down
12 changes: 12 additions & 0 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16369,7 +16369,10 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
created: function created() {
var vm = this;
var jq = vm.jq;
var orders = [];

var sort = 0;
var icol = 0;

// allow user to override default options
if (vm.opts) {
Expand Down Expand Up @@ -16418,9 +16421,18 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
// console.log(col)

cols.push(col);

if (col.defaultOrder) {
orders.push([icol, col.defaultOrder]);
}

icol++;
}
}

// apply orders calculated from above
vm.options.order = vm.options.order || orders;

if (vm.selectCheckbox) {
// expand column
var _col = {
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/index.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions lib/mix-manifest.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"/index.js": "/index.js?id=42c742b0948268c308ac",
"/index.js.map": "/index.js.map?id=9ac43f02d49480ed2578"
"/index.js": "/index.js?id=7ee15f6b617974705b45",
"/index.js.map": "/index.js.map?id=226097290267f14622d6"
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "vue-datatables-net",
"description": "Vue jQuery DataTables.net wrapper component",
"version": "1.0.1",
"version": "1.0.2",
"author": "[email protected]",
"license": "MIT",
"main": "lib/index.js",
Expand Down
18 changes: 15 additions & 3 deletions src/VdtnetTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,12 @@ export default {
}
},
created() {
const vm = this
const jq = vm.jq
let sort = 0
const vm = this
const jq = vm.jq
const orders = []
let sort = 0
let icol = 0
// allow user to override default options
if (vm.opts) {
Expand Down Expand Up @@ -186,9 +189,18 @@ export default {
// console.log(col)
cols.push(col)
if (col.defaultOrder) {
orders.push([icol, col.defaultOrder])
}
icol++
}
}
// apply orders calculated from above
vm.options.order = vm.options.order || orders
if (vm.selectCheckbox) {
// expand column
const col = {
Expand Down

0 comments on commit 70ca7fa

Please sign in to comment.