1
1
# gridjs-vue
2
2
3
- ![ gridjs-vue ] ( https://user-images.githubusercontent.com/2541728/84843482-ffc31c00-b015-11ea-95e8-dc6fb3931ad5.png )
3
+ < center >< img src = " https://user-images.githubusercontent.com/2541728/84843482-ffc31c00-b015-11ea-95e8-dc6fb3931ad5.png " alt = " gridjs-vue logo " /></ center >
4
4
5
+ <<<<<<< HEAD
5
6
A [ Vue.js] ( https://vuejs.org ) wrapper component for [ Grid.js] ( https://gridjs.io )
6
7
7
8
### 🏠 [ Homepage] ( https://gridjs.io )
9
+ =======
10
+ A Vue wrapper component for [ Grid.js] ( https://gridjs.io ) .
11
+ >>>>>>> e1c00e6... another attempt at importing cssing
8
12
9
13
## Install
10
14
11
15
``` sh
12
- yarn install gridjs-vue || npm install gridjs-vue
16
+ npm install gridjs-vue
13
17
```
14
18
15
- ## Component Registration
19
+ ### Component Registration
16
20
17
- ### Global Registration
21
+ #### Local Registration
18
22
19
- ``` js
20
- /* in `main.js` or wherever you specify your global components */
21
- import Grid from ' gridjs-vue'
23
+ ``` html
24
+ < script >
25
+ import Grid from ' gridjs-vue'
22
26
23
- Vue .use (Grid)
27
+ export default {
28
+ components: {
29
+ Grid
30
+ }
31
+ }
32
+ </script >
24
33
```
25
34
26
- ### Local Registration
35
+ #### Global Registration
27
36
28
- ``` vue
29
- <script>
37
+ ``` js
38
+ /* in `main.js` or wherever you specify your global components */
30
39
import Grid from ' gridjs-vue'
31
40
32
- export default {
33
- components: {
34
- Grid
35
- }
36
- }
37
- </script>
41
+ Vue .use (Grid)
38
42
```
39
43
40
44
## Usage
41
45
42
- Pass ` cols ` and either ` rows ` , ` from ` , or ` server ` as a data source. Everything else is optional.
46
+ Pass ` cols ` (an array of column headers) and either ` rows ` , ` from ` , or ` server ` as a data source to the component . Everything else is optional.
43
47
44
48
Refer to [ Grid.js documentation] ( https://gridjs.io/docs/config/ ) for specific configuration options.
45
49
46
- ``` vue
50
+ ### Basic Example
51
+
52
+ ``` html
47
53
<template >
48
- <grid
49
- :auto-width="autoWidth"
50
- :cols="cols"
51
- :from="from"
52
- :language="language"
53
- :pagination="pagination"
54
- :rows="rows"
55
- :search="search"
56
- :server="server"
57
- :sort="sort"
58
- :width="width"
59
- ></grid>
54
+ <grid :cols =" cols" :rows =" rows" ></grid >
60
55
</template >
61
56
62
57
<script >
63
- import Grid from 'gridjs-vue'
64
-
65
- export default {
66
- name: 'MyTable',
67
- components: {
68
- Grid
69
- },
70
- data() {
71
- return {
72
- autoWidth: true / false, // boolean to automatically set table width
73
- cols: ['column 1', 'column 2'], // array containing strings of column headers
74
- from: '.my-element', // string of HTML table selector
75
- language: {}, // localization dictionary object
76
- pagination: true / false || {}, // boolean or pagination settings object
77
- rows: ['row 1: col 1', 'row 1: col 2'] // array containing row data
78
- search: true / false || {}, // boolean or search settings object
79
- server: {}, // server settings object
80
- sort: true / false || {}, // boolean or sort settings object
81
- theme: 'mermaid', // string with name of theme or 'none' to disable
82
- width: '100%' // string with css width value
58
+ import Grid from ' gridjs-vue'
59
+
60
+ export default {
61
+ name: ' Cars' ,
62
+ components: {
63
+ Grid
64
+ },
65
+ data () {
66
+ return {
67
+ cols: [' Make' , ' Model' , ' Year' , ' Color' ],
68
+ rows: [
69
+ [' Ford' , ' Fusion' , ' 2011' , ' Silver' ],
70
+ [' Chevrolet' , ' Cruz' , ' 2018' , ' White' ]
71
+ ]
72
+ }
83
73
}
84
74
}
85
- }
86
75
</script >
87
76
```
88
77
89
- ### Default settings
78
+ ### Default Options
90
79
91
80
``` json
92
81
{
@@ -104,6 +93,85 @@ export default {
104
93
}
105
94
```
106
95
96
+ ### Extended Options
97
+
98
+ ``` html
99
+ <template >
100
+ <grid
101
+ :auto-width =" autoWidth"
102
+ :cols =" cols"
103
+ :from =" from"
104
+ :language =" language"
105
+ :pagination =" pagination"
106
+ :rows =" rows"
107
+ :search =" search"
108
+ :server =" server"
109
+ :sort =" sort"
110
+ :width =" width"
111
+ ></grid >
112
+ </template >
113
+
114
+ <script >
115
+ import Grid from ' gridjs-vue'
116
+
117
+ export default {
118
+ name: ' MyTable' ,
119
+ components: {
120
+ Grid
121
+ },
122
+ data () {
123
+ return {
124
+ // REQUIRED:
125
+
126
+ // An array containing strings of column headers
127
+ cols: [' col 1' , ' col 2' ],
128
+
129
+ // AND EITHER an array containing row data
130
+ rows: [
131
+ [' row 1 col 1' , ' row 1 col 2' ],
132
+ [' row 2 col 1' , ' row 2 col 2' ]
133
+ ],
134
+
135
+ // OR a string of an HTML table selector to import
136
+ from: ' .my-element'
137
+
138
+ // OR a server settings object
139
+ server () ({
140
+ url: ' https://api.com/search?q=my%20query' ,
141
+ then : res => res .data .map (col => [col1 .data , col2 .data ]),
142
+ handle : res => res .status === 404
143
+ ? { data: [] } : res .ok
144
+ ? res .json () : new Error (' Something went wrong' )
145
+ }),
146
+
147
+ // OPTIONAL:
148
+
149
+ // Boolean to automatically set table width
150
+ autoWidth: true / false ,
151
+
152
+ // Localization dictionary object
153
+ language: {},
154
+
155
+ // Boolean or pagination settings object
156
+ pagination: true / false || {},
157
+
158
+ // Boolean or search settings object
159
+ search: true / false || {},
160
+
161
+ // Boolean or sort settings object
162
+ sort: true / false || {},
163
+
164
+ // String with name of theme or 'none' to disable
165
+ theme: ' mermaid' ,
166
+
167
+ // String with css width value
168
+ width: ' 100%' ,
169
+ }
170
+ }
171
+ }
172
+ </script >
173
+ ```
174
+
107
175
## 🤝 Contributing
108
176
109
177
Originally authored by [ Daniel Sieradski] ( https://twitter.com/self_agency ) .
0 commit comments