Skip to content

Commit

Permalink
allow component export
Browse files Browse the repository at this point in the history
  • Loading branch information
noogen committed Nov 6, 2018
1 parent 4bb0f31 commit 17904ed
Show file tree
Hide file tree
Showing 9 changed files with 105 additions and 44 deletions.
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,18 @@ This is based on the configuration `lftiprB`, also see: https://datatables.net/r
Note, we do not include toolbar buttons (B) or search control (s). This is because we defer these functions to you (the User). Toolbar Buttons are client-side; and since we do not use client-side, we don't need these buttons. We expose a `search` method on `vdtnet-table` so you can use this method to perform search.
Simply create your own Buttons for server-side exports, bulk, and/or other things. Create your own search control and use the `search` method. See example App. All these things are now Vue Native.
Simply create your own Buttons for server-side exports, bulk, and/or other things. Create your own search control and use the `search` method. See example App. All these things are now Vue natives.
Though, if you want to use these client-side controls, you can freely override the default `opts.dom` and `opts.buttons` to show these controls.
Though, if you really insists on using these client-side controls, simply override the default `opts.dom` and `opts.buttons` with your own settings.
## getServerParams method
This function return the parameters last used by our server-side endpoint. It allow you to use for server-side export API call. Example:
```javascript
const parms = this.$refs.table.getServerParams()
parms.export = 'csv'
// boom export
const url = 'export.php?' + $.param(data)
window.open(url)
```
# MIT
100 changes: 68 additions & 32 deletions dist/index.js

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

17 changes: 14 additions & 3 deletions example/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,15 @@
<div class="row">
<div class="col-sm-12 col-md-9">
<div class="dt-buttons btn-group">
<button class="btn btn-secondary buttons-copy buttons-html5">button1</button>
<button class="btn btn-secondary buttons-copy buttons-html5">button2</button>
<button class="btn btn-secondary buttons-copy buttons-html5">button3</button>
<button
class="btn btn-secondary buttons-copy buttons-html5"
@click.stop.prevent="doExport('csv')">Csv</button>
<button
class="btn btn-secondary buttons-copy buttons-html5"
@click.stop.prevent="doExport('excel')">Excel</button>
<button
class="btn btn-secondary buttons-copy buttons-html5"
@click.stop.prevent="doExport('pdf')">Pdf</button>
</div>
</div>
<div class="col-sm-12 col-md-3">
Expand Down Expand Up @@ -143,6 +149,11 @@ export default {
},
doSearch() {
this.$refs.table.search(this.quickSearch)
},
doExport(type) {
const parms = this.$refs.table.getServerParams()
parms.export = type
window.alert('GET /api/v1/export?' + jQuery.param(parms))
}
}
}
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=4fefe56af56c9ec3399a",
"/index.js.map": "/index.js.map?id=7ebc3389f1cdc2b39e2b"
"/index.js": "/index.js?id=e775a1751601ca0031a7",
"/index.js.map": "/index.js.map?id=1e736317f97d0a52165b"
}
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": "0.9.4",
"version": "0.9.5",
"author": "[email protected]",
"license": "MIT",
"main": "lib/index.js",
Expand Down
6 changes: 5 additions & 1 deletion src/VdtnetTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,9 @@ export default {
language: {
infoFiltered: ''
},
lengthMenu: [ [10, 100, 500, 1000, -1], [10, 100, 500, 1000, 'All'] ],
lengthMenu: [ [15, 100, 500, 1000, -1], [15, 100, 500, 1000, 'All'] ],
responsive: true,
pageLength: 15,
buttons: [] // remove any button defaults
},
dataTable: null
Expand Down Expand Up @@ -320,6 +321,9 @@ export default {
const vm = this
vm.dataTable.page.len( value )
return vm.reload()
},
getServerParams() {
return this.dataTable.ajax.params()
}
}
}
Expand Down

0 comments on commit 17904ed

Please sign in to comment.