Skip to content

Commit d441bb4

Browse files
committed
update doc, peer deps
1 parent faab2ae commit d441bb4

File tree

10 files changed

+124
-57
lines changed

10 files changed

+124
-57
lines changed

README.md

Lines changed: 45 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -107,44 +107,52 @@ Since it's a wrapper, all/most features are provided by the [jQuery DataTables](
107107
## Parameters
108108
Our component parameters:
109109
```javascript
110-
props: {
111-
// Set the table classes you wish to use, default with bootstrap4
112-
// but you can override with: themeforest, foundation, etc..
113-
className: {
114-
type: String,
115-
default: 'table table-striped table-bordered dt-responsive nowrap w-100'
116-
},
117-
// the options object: https://datatables.net/manual/options
118-
opts: {
119-
type: Object
120-
},
121-
/**
122-
* List all fields to be converted to opts columns
123-
*
124-
* @type {Object}
125-
*/
126-
fields: {
127-
type: Object
128-
},
129-
/**
130-
* Pass in DataTables.Net loaded jQuery to resolve
131-
* any multiple loaded browser jQuery conflict
132-
*
133-
* @type {Object}
134-
*/
135-
jquery: {
136-
type: Object
137-
},
138-
/**
139-
* True to enable multi-select checkboxes
140-
* Current implementation require datatables.net-select
141-
*
142-
* @type Boolean
143-
*/
144-
selectable: {
145-
type: Boolean
110+
props: {
111+
/**
112+
* Set the table classes you wish to use, default with bootstrap4
113+
* but you can override with: themeforest, foundation, etc..
114+
*
115+
* @type String
116+
*/
117+
className: {
118+
type: String,
119+
default: 'table table-striped table-bordered nowrap w-100'
120+
},
121+
/**
122+
* the options object: https://datatables.net/manual/options
123+
*
124+
* @type Object
125+
*/
126+
opts: {
127+
type: Object
128+
},
129+
/**
130+
* List all fields to be converted to opts columns
131+
*
132+
* @type Object
133+
*/
134+
fields: {
135+
type: Object
136+
},
137+
/**
138+
* Pass in DataTables.Net loaded jQuery to resolve
139+
* any multiple loaded browser jQuery conflict
140+
*
141+
* @type Object
142+
*/
143+
jquery: {
144+
type: Object
145+
},
146+
/**
147+
* True to enable multi-select checkboxes
148+
* Current implementation require datatables.net-select
149+
*
150+
* @type Boolean
151+
*/
152+
selectable: {
153+
type: Boolean
154+
}
146155
}
147-
},
148156
```
149157

150158
`fields` is an schema object that identify all datatables.net columns, example:

dist/index.js

Lines changed: 37 additions & 7 deletions
Large diffs are not rendered by default.

dist/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.

example/App.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ export default {
6060
lengthChange: true,
6161
serverSide: true,
6262
fixedHeader: true,
63+
saveState: true,
6364
buttons: ['copy', 'csv', 'print']
6465
},
6566
fields: {

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=542b91159c8523321093",
3-
"/index.js.map": "/index.js.map?id=3bc06a22bacc66deaa63"
2+
"/index.js": "/index.js?id=5ee5f53ccf2d5efe4573",
3+
"/index.js.map": "/index.js.map?id=4dc5128abdf6f7ba4dea"
44
}

package-lock.json

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

package.json

Lines changed: 2 additions & 2 deletions
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": "0.9.0",
4+
"version": "0.9.1",
55
"author": "[email protected]",
66
"license": "MIT",
77
"main": "lib/index.js",
@@ -30,7 +30,7 @@
3030
"not ie <= 8"
3131
],
3232
"peerDependencies": {
33-
"datatables.net": "^1.10.19",
33+
"jquery": ">=1.7",
3434
"vue": ">=2.0.0"
3535
},
3636
"devDependencies": {

src/VdtnetTable.vue

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,28 @@
3131
export default {
3232
name: 'VdtnetTable',
3333
props: {
34-
// Set the table classes you wish to use, default with bootstrap4
35-
// but you can override with: themeforest, foundation, etc..
34+
/**
35+
* Set the table classes you wish to use, default with bootstrap4
36+
* but you can override with: themeforest, foundation, etc..
37+
*
38+
* @type String
39+
*/
3640
className: {
3741
type: String,
3842
default: 'table table-striped table-bordered nowrap w-100'
3943
},
40-
// the options object: https://datatables.net/manual/options
44+
/**
45+
* the options object: https://datatables.net/manual/options
46+
*
47+
* @type Object
48+
*/
4149
opts: {
4250
type: Object
4351
},
4452
/**
4553
* List all fields to be converted to opts columns
4654
*
47-
* @type {Object}
55+
* @type Object
4856
*/
4957
fields: {
5058
type: Object
@@ -53,7 +61,7 @@ export default {
5361
* Pass in DataTables.Net loaded jQuery to resolve
5462
* any multiple loaded browser jQuery conflict
5563
*
56-
* @type {Object}
64+
* @type Object
5765
*/
5866
jquery: {
5967
type: Object
@@ -239,6 +247,13 @@ export default {
239247
}
240248
})
241249
},
250+
beforeDestroy() {
251+
const vm = this
252+
if (vm.dataTable) {
253+
vm.dataTable.destroy(true)
254+
}
255+
vm.dataTable = null
256+
},
242257
methods: {
243258
compileTemplate(template) {
244259
const vm = this
@@ -259,6 +274,19 @@ export default {
259274
}
260275
261276
return renderFunc
277+
},
278+
/**
279+
* Set table data array that was loaded from somewhere else
280+
* This method allow for local setting of data; though, it
281+
* is recommended to use ajax instead of this.
282+
*
283+
* @param Array data the array of data
284+
*/
285+
setTableData(data) {
286+
const vm = this
287+
vm.dataTable.clear().rows.add(data)
288+
vm.dataTable.draw(false)
289+
vm.dataTable.columns.adjust()
262290
}
263291
}
264292
}

0 commit comments

Comments
 (0)