Skip to content

Commit

Permalink
fix default sort orderingg
Browse files Browse the repository at this point in the history
  • Loading branch information
noogen committed Dec 4, 2018
1 parent 5852569 commit a332313
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 29 deletions.
32 changes: 18 additions & 14 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,8 @@ __webpack_require__.r(__webpack_exports__);
name: {
label: 'Name',
sortable: true,
searchable: true
searchable: true,
defaultOrder: 'desc'
},
username: {
label: 'Username',
Expand Down Expand Up @@ -417,8 +418,6 @@ __webpack_require__.r(__webpack_exports__);

"use strict";
__webpack_require__.r(__webpack_exports__);
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

//
//
//
Expand Down Expand Up @@ -568,7 +567,7 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
var vm = this;
var jq = vm.jq;
var orders = [];
var sort = 0;
var startCol = 0;
var icol = 0; // allow user to override default options

if (vm.opts) {
Expand Down Expand Up @@ -618,7 +617,7 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
cols.push(col);

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

icol++;
Expand Down Expand Up @@ -646,29 +645,34 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
});

if (vm.selectCheckbox == 1) {
sort++;
startCol++;
}
} // handle master details


if (vm.details) {
var _col2 = _defineProperty({
var _col2 = {
orderable: false,
name: '_details_control',
className: 'details-control',
data: null,
defaultContent: ''
}, "defaultContent", vm.details.icons || '<span class="details-plus" title="Show details">+</span><span class="details-minus" title="Hide details">-</span>');

defaultContent: vm.details.icons || '<span class="details-plus" title="Show details">+</span><span class="details-minus" title="Hide details">-</span>'
};
vm.options.columns.splice((vm.details.index || 1) - 1, 0, _col2);

if ((vm.details.index || 1) > 0) {
sort++;
if ((vm.details.index || 1) == 1) {
startCol++;
}
}

if (sort > 0) {
vm.options.order = [[sort, 'asc']];
if (startCol > 0) {
if (vm.options.order) {
vm.options.order.forEach(function (v) {
v[0] += startCol;
});
} else {
vm.options.order = [[startCol, 'asc']];
}
} // handle local data loader


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 example/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export default {
defaultContent: '<a href="javascript:void(0);" data-action="edit" class="btn btn-primary btn-sm"><i class="mdi mdi-square-edit-outline"></i> Edit</a>' +
'<span data-action="delete" class="btn btn-danger btn-sm"><i class="mdi mdi-delete"></i> Delete</span>'
},
name: { label: 'Name', sortable: true, searchable: true },
name: { label: 'Name', sortable: true, searchable: true, defaultOrder: 'desc' },
username: { label: 'Username', sortable: false, searchable: true },
email: { label: 'Email' },
address: {
Expand Down
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=7d78e1d531f475e0ec43",
"/index.js.map": "/index.js.map?id=0674e31b844d15842eac"
"/index.js": "/index.js?id=38a14d55a59f54e057f6",
"/index.js.map": "/index.js.map?id=a560110cdf7ce9aa9f00"
}
23 changes: 14 additions & 9 deletions src/VdtnetTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ export default {
const jq = vm.jq
const orders = []
let sort = 0
let icol = 0
let startCol = 0
let icol = 0
// allow user to override default options
if (vm.opts) {
Expand Down Expand Up @@ -191,7 +191,7 @@ export default {
cols.push(col)
if (field.defaultOrder) {
orders.push([icol, col.defaultOrder])
orders.push([icol, field.defaultOrder])
}
icol++
Expand Down Expand Up @@ -223,7 +223,7 @@ export default {
)
if (vm.selectCheckbox == 1) {
sort++
startCol++
}
}
Expand All @@ -234,18 +234,23 @@ export default {
name: '_details_control',
className: 'details-control',
data: null,
defaultContent: '',
defaultContent: vm.details.icons || '<span class="details-plus" title="Show details">+</span><span class="details-minus" title="Hide details">-</span>'
}
vm.options.columns.splice((vm.details.index || 1) - 1, 0, col)
if ((vm.details.index || 1) > 0) {
sort++
if ((vm.details.index || 1) == 1) {
startCol++
}
}
if (sort > 0) {
vm.options.order = [[sort, 'asc']]
if (startCol > 0) {
if (vm.options.order) {
vm.options.order.forEach((v) => {
v[0] += startCol
})
} else {
vm.options.order = [[startCol, 'asc']]
}
}
// handle local data loader
Expand Down

0 comments on commit a332313

Please sign in to comment.