Skip to content

Commit

Permalink
disable search and sort for local/utility/actions column
Browse files Browse the repository at this point in the history
  • Loading branch information
noogen committed Apr 10, 2019
1 parent 83a7c3f commit 78dad9d
Show file tree
Hide file tree
Showing 8 changed files with 138 additions and 48 deletions.
33 changes: 25 additions & 8 deletions example/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -564,15 +564,19 @@ __webpack_require__.r(__webpack_exports__);

for (var k in fields) {
var field = fields[k];
field.name = field.name || k; // generate
field.name = field.name || k; // disable search and sort for local field

if (field.utility) {
field.searchable = false;
field.orderable = false;
} // generate


var col = {
searchable: field.searchable,
title: field.label || k,
title: field.label || field.name,
width: field.width,
data: field.name,
name: field.name,
visible: field.visible,
className: field.className
};

Expand All @@ -588,6 +592,14 @@ __webpack_require__.r(__webpack_exports__);
col.orderable = field.sortable;
}

if (field.hasOwnProperty('visible')) {
col.visible = field.visible;
}

if (field.hasOwnProperty('searchable')) {
col.searchable = field.searchable;
}

if (field.template) {
field.render = vm.compileTemplate(field.template);
}
Expand All @@ -611,9 +623,11 @@ __webpack_require__.r(__webpack_exports__);
vm.options.order = vm.options.order || orders;

if (vm.selectCheckbox) {
// expand column
vm.selectCheckbox = vm.selectCheckbox || 1; // create checkbox column

var _col = {
orderable: false,
searchable: false,
name: '_select_checkbox',
className: 'select-checkbox',
data: null,
Expand All @@ -627,23 +641,26 @@ __webpack_require__.r(__webpack_exports__);
selector: 'td.select-checkbox'
});

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


if (vm.details) {
vm.details.index = vm.details.index || 1; // create details column

var _col2 = {
orderable: false,
searchable: false,
name: '_details_control',
className: 'details-control',
data: null,
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);
vm.options.columns.splice(vm.details.index - 1, 0, _col2);

if ((vm.details.index || 1) == 1) {
if (vm.details.index === 1) {
startCol++;
}
}
Expand Down
2 changes: 1 addition & 1 deletion example/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=c08c4f48a07c95268018",
"/index.js.map": "/index.js.map?id=b617366060d9755b0741"
"/index.js": "/index.js?id=4a6b72e261b73b7deb79",
"/index.js.map": "/index.js.map?id=31baa2ad4a62573e0529"
}
90 changes: 70 additions & 20 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"vue": ">=2.0.0"
},
"devDependencies": {
"@babel/core": "^7.3.4",
"@babel/core": "^7.4.3",
"@babel/plugin-syntax-dynamic-import": "^7.2.0",
"babel-eslint": "^10.0.1",
"bootstrap": "^4.3.1",
Expand All @@ -44,7 +44,7 @@
"css-loader": "^2.1.0",
"datatables.net-bs4": "^1.10.19",
"datatables.net-select-bs4": "^1.2.7",
"eslint": "^5.14.1",
"eslint": "^5.16.0",
"eslint-config-prettier": "^4.1.0",
"eslint-friendly-formatter": "^4.0.1",
"eslint-loader": "^2.1.2",
Expand Down
49 changes: 36 additions & 13 deletions src/VdtnetTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -155,17 +155,21 @@ export default {
for (let k in fields) {
const field = fields[k]
field.name = field.name || k
field.name = field.name || k
// disable search and sort for local field
if (field.utility) {
field.searchable = false
field.orderable = false
}
// generate
let col = {
searchable: field.searchable,
title: field.label || k,
width: field.width,
data: field.name,
name: field.name,
visible: field.visible,
className: field.className
title: field.label || field.name,
width: field.width,
data: field.name,
name: field.name,
className: field.className
}
if (field.width) {
Expand All @@ -180,15 +184,23 @@ export default {
col.orderable = field.sortable
}
if (field.hasOwnProperty('visible')) {
col.visible = field.visible
}
if (field.hasOwnProperty('searchable')) {
col.searchable = field.searchable
}
if (field.template) {
field.render = vm.compileTemplate(field.template)
}
if (field.render) {
col.render = field.render
}
// console.log(col)
// console.log(col)
cols.push(col)
if (field.defaultOrder) {
Expand All @@ -203,9 +215,12 @@ export default {
vm.options.order = vm.options.order || orders
if (vm.selectCheckbox) {
// expand column
vm.selectCheckbox = vm.selectCheckbox || 1
// create checkbox column
const col = {
orderable: false,
searchable: false,
name: '_select_checkbox',
className: 'select-checkbox',
data: null,
Expand All @@ -223,23 +238,27 @@ export default {
}
)
if (vm.selectCheckbox == 1) {
if (vm.selectCheckbox === 1) {
startCol++
}
}
// handle master details
if (vm.details) {
vm.details.index = vm.details.index || 1
// create details column
const col = {
orderable: false,
searchable: false,
name: '_details_control',
className: 'details-control',
data: null,
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)
vm.options.columns.splice(vm.details.index - 1, 0, col)
if ((vm.details.index || 1) == 1) {
if (vm.details.index === 1) {
startCol++
}
}
Expand Down Expand Up @@ -377,6 +396,7 @@ export default {
if (vm.dataTable) {
vm.dataTable.destroy(true)
}
vm.dataTable = null
},
methods: {
Expand Down Expand Up @@ -450,17 +470,20 @@ export default {
search(value) {
const vm = this
vm.dataTable.search( value ).draw()
return vm
},
setPageLength(value) {
const vm = this
vm.dataTable.page.len( value )
return vm.reload()
},
getServerParams() {
if (this.dataLoader) {
return {}
}
return this.dataTable.ajax.params()
}
}
Expand Down

0 comments on commit 78dad9d

Please sign in to comment.