Skip to content

Commit 818f23b

Browse files
committed
update demo
1 parent 3e9e032 commit 818f23b

File tree

10 files changed

+3993
-285
lines changed

10 files changed

+3993
-285
lines changed

README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,29 @@ window.open(url)
327327
render: 'provide a custom render function as alternative to template'
328328
}
329329
```
330+
## Export
331+
This is something you want to explore on your own. We try our best to provide as much example of export as possible in our demo, but Server-Side and/or Language/Framework Specific Code is too much/time-consuming to dive into. Also, sometime output rendering are ties to specific requirement and cannot generically meet everyone needs. We suggest that you create a Bounty for your specific needs.
332+
333+
**Client-Side**
334+
This is mostly provided by jQuery DataTables. We demonstrate in our default demo. You can find the documentation for [Buttons](https://datatables.net/extensions/buttons/) directly on the jQuery DataTables website.
335+
336+
**Server-Side**
337+
Our demo for server-side export is here: https://laratt.niiknow.org/home/contacts
338+
339+
The source of the demo can be found here: https://github.com/niiknow/laratt-api
340+
And, specifically, the client-side vue component usage source: https://github.com/niiknow/laratt-api/blob/5117bfae1273b31f95af6aa99c51aae7fc413d2f/resources/js/components/DataTableNet.vue#L148
341+
342+
The code use `convention` to calculate a route/url as:
343+
```
344+
url: that.$app.apiRoute(that.rName, that.rPath),
345+
```
346+
347+
Which result to a URL like so: https://laratt.niiknow.org/api/v1/democontact/example?x-tenant=test&x-api-key=demo123
348+
349+
And the server-side source for the export is simply: https://github.com/niiknow/laratt-api/blob/876ce385fc64d83b564f2e697790465675741634/api/Controllers/DemoContactController.php#L90
350+
351+
**Export Tip**
352+
Outside of csv export, most modern OS and Browser support PDF printing. As a result, simply instruct the user to Print your page and use printing CSS to manipulate for exporting of PDF.
330353
331354
## Tips
332355
If you're like us, you want to write as little code as possible; as in, application of the DRY Principle. This mean the UI has a standard look/feel/behavior; where toolbar, search, and other controls are place at specific location. So this mean you want to wrap this component inside your own component? Our sample App give you a good idea on how to start. Below are a few things to consider:

example/app.vue

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,13 @@
55
>
66
<div class="row">
77
<div class="col-12 col-md-9">
8-
<div class="dt-buttons btn-group">
9-
<button
10-
class="btn btn-secondary buttons-copy buttons-html5"
11-
@click.stop.prevent="doExport('csv')"
12-
>
13-
Csv
14-
</button>
15-
<button
16-
class="btn btn-secondary buttons-copy buttons-html5"
17-
@click.stop.prevent="doExport('excel')"
18-
>
19-
Excel
20-
</button>
21-
<button
22-
class="btn btn-secondary buttons-copy buttons-html5"
23-
@click.stop.prevent="doExport('pdf')"
24-
>
25-
Pdf
26-
</button>
27-
</div>
8+
Below are client-side buttons demo, go here to see
9+
<a
10+
href="https://laratt.niiknow.org/home/contacts"
11+
target="_blank"
12+
>
13+
server-side buttons demo
14+
</a>
2815
</div>
2916
<div class="col-12 col-md-3">
3017
<form
@@ -71,15 +58,20 @@
7158
<script>
7259
// this demonstrate with buttons and responsive master/details row
7360
import VdtnetTable from '../src'
74-
// since I already include on index.html, I don't need to include it here
75-
// import 'datatables.net/js/jquery.dataTables.js'
76-
import 'datatables.net-bs4/js/dataTables.bootstrap4.js'
61+
62+
import 'datatables.net-bs4'
63+
64+
// import buttons and plugins
65+
import 'datatables.net-buttons/js/dataTables.buttons.js'
66+
import 'datatables.net-buttons/js/buttons.html5.js'
67+
import 'datatables.net-buttons/js/buttons.print.js'
7768
7869
// import the rest
70+
import 'datatables.net-buttons-bs4'
7971
import 'datatables.net-select-bs4'
8072
81-
import 'datatables.net-bs4/css/dataTables.bootstrap4.min.css'
8273
import 'datatables.net-select-bs4/css/select.bootstrap4.min.css'
74+
import 'datatables.net-buttons-bs4/css/buttons.bootstrap4.min.css'
8375
8476
export default {
8577
name: 'App',
@@ -95,6 +87,10 @@ export default {
9587
return json
9688
}
9789
},
90+
buttons: ['copy', 'csv', 'print'],
91+
/*eslint-disable */
92+
dom: "Btr<'row vdtnet-footer'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7'pl>>",
93+
/*eslint-enable */
9894
responsive: false,
9995
processing: true,
10096
searching: true,

example/index.js

Lines changed: 3889 additions & 241 deletions
Large diffs are not rendered by default.

example/index.js.map

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

lib/index.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.

lib/index.js.map

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

lib/mix-manifest.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"/index.js": "/index.js?id=32ec8b280fd84173c683",
3-
"/index.js.map": "/index.js.map?id=642f9a187e8ecd87f3ed"
2+
"/index.js": "/index.js?id=3560ad448a37fa3d71c5",
3+
"/index.js.map": "/index.js.map?id=aec5afec3dd3eab095f2"
44
}

package-lock.json

Lines changed: 51 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "vue-datatables-net",
33
"description": "Vue jQuery DataTables.net wrapper component",
4-
"version": "1.1.2",
4+
"version": "1.1.3",
55
"author": "[email protected]",
66
"license": "MIT",
77
"main": "lib/index.js",
@@ -43,6 +43,7 @@
4343
"cross-env": "^5.1.6",
4444
"css-loader": "^2.1.0",
4545
"datatables.net-bs4": "^1.10.19",
46+
"datatables.net-buttons-bs4": "^1.5.6",
4647
"datatables.net-select-bs4": "^1.2.7",
4748
"eslint": "^5.16.0",
4849
"eslint-config-prettier": "^4.2.0",

src/VdtnetTable.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -222,10 +222,10 @@ export default {
222222
orderable: false,
223223
searchable: false,
224224
name: '_select_checkbox',
225-
className: 'select-checkbox',
225+
className: 'select-checkbox d-print-none',
226226
data: null,
227227
defaultContent: '',
228-
title: '<input type="checkbox" class="select-all-checkbox">'
228+
title: '<input type="checkbox" class="select-all-checkbox d-print-none">'
229229
}
230230
vm.options.columns.splice(vm.selectCheckbox - 1, 0, col)
231231
@@ -252,7 +252,7 @@ export default {
252252
orderable: false,
253253
searchable: false,
254254
name: '_details_control',
255-
className: 'details-control',
255+
className: 'details-control d-print-none',
256256
data: null,
257257
defaultContent: vm.details.icons || '<span class="details-plus" title="Show details">+</span><span class="details-minus" title="Hide details">-</span>'
258258
}

0 commit comments

Comments
 (0)