Skip to content

Commit 995c66b

Browse files
committed
Change attribute names to match GridJS API
Signed-off-by: Daniel Sieradski <daniel@self.agency>
1 parent abdaa15 commit 995c66b

File tree

5 files changed

+31
-32
lines changed

5 files changed

+31
-32
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
All notable changes to this project will be documented in this file. Dates are displayed in UTC.
44

5+
## [Unreleased]
6+
57
## [5.0.1] - 2021-06-08
68

79
- Major update!

README.md

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@ Vue.use(GridGlobal)
3939

4040
## Usage
4141

42-
Pass `cols` (an array of column headers) and either `rows`, `from`, or `server` as a data source to the component. Everything else is optional. Pass in new data to update the table.
42+
Pass `columns` (an array of column headers) and either `rows`, `from`, or `server` as a data source to the component. Everything else is optional. Pass in new data to update the table.
4343

4444
Refer to [Grid.js documentation](https://gridjs.io/docs/config/) for specific configuration options. This module may lag behind the main Grid.js module somewhat, so check the API version badge at the top of this README.
4545

4646
### Basic Example
4747

4848
```html
4949
<template>
50-
<grid :cols="cols" :rows="rows"></grid>
50+
<grid :columns="columns" :rows="rows"></grid>
5151
</template>
5252

5353
<script>
@@ -60,7 +60,7 @@ Refer to [Grid.js documentation](https://gridjs.io/docs/config/) for specific co
6060
},
6161
data() {
6262
return {
63-
cols: ['Make', 'Model', 'Year', 'Color'],
63+
columns: ['Make', 'Model', 'Year', 'Color'],
6464
rows: [
6565
['Ford', 'Fusion', '2011', 'Silver'],
6666
['Chevrolet', 'Cruz', '2018', 'White']
@@ -76,16 +76,16 @@ Refer to [Grid.js documentation](https://gridjs.io/docs/config/) for specific co
7676
```json
7777
{
7878
"autoWidth": true,
79-
"classNames": undefined,
80-
"cols": [""],
79+
"className": undefined,
80+
"columns": [""],
8181
"from": undefined,
8282
"language": undefined,
8383
"pagination": false,
8484
"rows": undefined,
8585
"search": false,
8686
"server": undefined,
8787
"sort": false,
88-
"styles": undefined,
88+
"style": undefined,
8989
"theme": "mermaid",
9090
"width": "100%"
9191
}
@@ -97,16 +97,16 @@ Refer to [Grid.js documentation](https://gridjs.io/docs/config/) for specific co
9797
<template>
9898
<grid
9999
:auto-width="autoWidth"
100-
:class-names="classNames"
101-
:cols="cols"
100+
:class-name="className"
101+
:columns="columns"
102102
:from="from"
103103
:language="language"
104104
:pagination="pagination"
105105
:rows="rows"
106106
:search="search"
107107
:server="server"
108108
:sort="sort"
109-
:styles="styles"
109+
:style="style"
110110
:width="width"
111111
></grid>
112112
</template>
@@ -124,11 +124,10 @@ Refer to [Grid.js documentation](https://gridjs.io/docs/config/) for specific co
124124
// REQUIRED:
125125
126126
// An array containing strings of column headers
127-
// `columns` in the Grid.js API
128-
cols: ['col 1', 'col 2'],
127+
columns: ['col 1', 'col 2'],
129128
130129
// OR an array containing objects defining column headers
131-
cols: [
130+
columns: [
132131
{
133132
name: 'Column 1',
134133
id: 'col1'
@@ -189,8 +188,7 @@ Refer to [Grid.js documentation](https://gridjs.io/docs/config/) for specific co
189188
autoWidth: true / false,
190189
191190
// Object with CSS class names
192-
// `className` in the Grid.js API
193-
classNames: {},
191+
className: {},
194192
195193
// Localization dictionary object
196194
language: {},
@@ -205,11 +203,10 @@ Refer to [Grid.js documentation](https://gridjs.io/docs/config/) for specific co
205203
sort: true / false || {},
206204
207205
// Object with CSS styles
208-
// `style` in the Grid.js API
209-
styles: {},
206+
style: {},
210207
211208
// String with name of theme or 'none' to disable
212-
theme: 'mermaid',
209+
theme: 'mermaid' || 'none',
213210
214211
// String with css width value
215212
width: '100%',
@@ -240,7 +237,7 @@ Renders a [Preact virtual DOM instance](https://gridjs.io/docs/examples/virtual-
240237
Usage:
241238

242239
```js
243-
this.cols = [
240+
this.columns = [
244241
{
245242
name: 'Actions',
246243
formatter: (cell, row) => {
@@ -263,7 +260,7 @@ Renders [HTML in a formatter function](https://gridjs.io/docs/examples/html-cell
263260
Example:
264261

265262
```js
266-
this.cols = [
263+
this.columns = [
267264
{
268265
name: 'Model',
269266
formatter: cell => this.$gridjs.html(`<b>${cell}</b>`)
@@ -290,7 +287,7 @@ import FormatterComponent from './FormatterComponent.vue'
290287

291288
[...]
292289

293-
this.cols = [
290+
this.columns = [
294291
{
295292
name: 'Model',
296293
formatter: cell => {

src/gridjs-vue.mjs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ export default {
2828
type: Boolean,
2929
default: true
3030
},
31-
classNames: {
31+
className: {
3232
type: Object,
3333
default: undefined
3434
},
35-
cols: {
35+
columns: {
3636
type: [Array, Function],
3737
default: undefined
3838
},
@@ -99,14 +99,14 @@ export default {
9999
options() {
100100
let options = {
101101
autoWidth: this.autoWidth,
102-
columns: this.cols ? this.cols : [this.dict.error.columnsUndefined],
102+
columns: this.columns ? this.columns : [this.dict.error.columnsUndefined],
103103
data: this.tabularData,
104104
pagination: this.pagination,
105105
sort: this.sort,
106106
width: this.width
107107
}
108108

109-
if (this.classNames) options.className = this.classNames
109+
if (this.className) options.className = this.className
110110
if (this.from)
111111
options.from =
112112
typeof this.from === 'string'
@@ -115,7 +115,7 @@ export default {
115115
if (this.language) options.language = this.language
116116
if (this.search) options.search = this.search
117117
if (this.server) options.server = this.server
118-
if (this.styles) options.style = this.styles
118+
if (this.style) options.style = this.style
119119

120120
return options
121121
},
@@ -132,10 +132,10 @@ export default {
132132
autoWidth() {
133133
this.update()
134134
},
135-
classNames() {
135+
className() {
136136
this.update()
137137
},
138-
cols() {
138+
columns() {
139139
this.update()
140140
},
141141
from() {
@@ -159,7 +159,7 @@ export default {
159159
sort() {
160160
this.update()
161161
},
162-
styles() {
162+
style() {
163163
this.update()
164164
},
165165
theme() {

test/gridjs-vue-test-no-theme.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export default {
77
},
88
data() {
99
return {
10-
cols: ['Permit Type', 'Capacity', 'Issued', 'Waiting', 'Notified', '%Sold'],
10+
columns: ['Permit Type', 'Capacity', 'Issued', 'Waiting', 'Notified', '%Sold'],
1111
rows: [
1212
['Commuter', 1000, 150, 20, 10, 15],
1313
['Disability', 50, 50, 0, 0, 100],
@@ -21,6 +21,6 @@ export default {
2121
}
2222
},
2323
template: `
24-
<div><grid :cols="cols" :rows="rows" :search="true" :sort="true" theme="none"></grid></div>
24+
<div><grid :columns="columns" :rows="rows" :search="true" :sort="true" theme="none"></grid></div>
2525
`
2626
}

test/gridjs-vue-test.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export default {
77
},
88
data() {
99
return {
10-
cols: ['Permit Type', 'Capacity', 'Issued', 'Waiting', 'Notified', '%Sold'],
10+
columns: ['Permit Type', 'Capacity', 'Issued', 'Waiting', 'Notified', '%Sold'],
1111
rows: [
1212
['Commuter', 1000, 150, 20, 10, 15],
1313
['Disability', 50, 50, 0, 0, 100],
@@ -21,6 +21,6 @@ export default {
2121
}
2222
},
2323
template: `
24-
<div><grid :cols="cols" :rows="rows" :search="true" :sort="true"></grid></div>
24+
<div><grid :columns="columns" :rows="rows" :search="true" :sort="true"></grid></div>
2525
`
2626
}

0 commit comments

Comments
 (0)