Skip to content

Commit a2b4c4e

Browse files
committed
📝 more cleanup
1 parent 7779481 commit a2b4c4e

File tree

1 file changed

+91
-91
lines changed

1 file changed

+91
-91
lines changed

README.md

Lines changed: 91 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -71,97 +71,6 @@ Refer to [Grid.js documentation](https://gridjs.io/docs/config/) for specific co
7171
</script>
7272
```
7373

74-
### Helper Functions
75-
76-
If you install the component globally, rather than importing it locally, the following helpers are added to the Vue prototype and are available globally.
77-
78-
#### \$gridjs.uuid
79-
80-
Returns a unique identifier that can be used to reference the current cell.
81-
82-
Usage:
83-
84-
```js
85-
const ref = this.$gridjs.uuid()
86-
```
87-
88-
#### \$gridjs.h
89-
90-
Renders a [Preact virtual DOM instance](https://gridjs.io/docs/examples/virtual-dom). Grid.js is built in Preact, so why not take advantage of it?
91-
92-
Usage:
93-
94-
```js
95-
this.cols = [
96-
{
97-
name: 'Actions',
98-
formatter: (cell, row) => {
99-
return this.$gridjs.h('button', {
100-
className: 'py-2 mb-4 px-4 border rounded-md text-white bg-blue-600',
101-
onClick: () => alert(`Editing "${row.cells[0].data}" "${row.cells[1].data}"`)
102-
} 'Edit');
103-
}
104-
},
105-
{ ... },
106-
{ ... }
107-
]
108-
```
109-
110-
#### \$gridjs.html
111-
112-
Renders [HTML in a formatter function](https://gridjs.io/docs/examples/html-cells).
113-
114-
Example:
115-
116-
```js
117-
this.cols = [
118-
{
119-
name: 'Model',
120-
formatter: cell => this.$gridjs.html(`<b>${cell}</b>`)
121-
},
122-
{ ... },
123-
{ ... }
124-
]
125-
```
126-
127-
#### \$gridjs.render
128-
129-
Renders a Vue component. Refer to [Vue documentation](https://vuejs.org/v2/guide/render-function.html#createElement-Arguments) for advanced options.
130-
131-
Usage:
132-
133-
```js
134-
this.$gridjs.render(ref, component, { props }, { options })
135-
```
136-
137-
Example:
138-
139-
```js
140-
import FormatterComponent from './FormatterComponent.vue'
141-
142-
[...]
143-
144-
this.cols = [
145-
{
146-
name: 'Model',
147-
formatter: cell => {
148-
const current = this.$gridjs.uuid()
149-
this.$gridjs.render(
150-
`[data-ref="${current}"]`,
151-
FormatterComponent,
152-
{
153-
content: cell,
154-
otherProp: true
155-
}
156-
)
157-
return this.$gridjs.html(`<div data-ref="${current}"></div>`)
158-
}
159-
},
160-
{ ... },
161-
{ ... }
162-
]
163-
```
164-
16574
### Default Options
16675

16776
```json
@@ -306,6 +215,97 @@ this.cols = [
306215
</script>
307216
```
308217

218+
### Helper Functions
219+
220+
If you install the component globally, rather than importing it locally, the following helpers are added to the Vue prototype and are available globally.
221+
222+
#### \$gridjs.uuid
223+
224+
Returns a unique identifier that can be used to reference the current cell.
225+
226+
Usage:
227+
228+
```js
229+
const ref = this.$gridjs.uuid()
230+
```
231+
232+
#### \$gridjs.h
233+
234+
Renders a [Preact virtual DOM instance](https://gridjs.io/docs/examples/virtual-dom). Grid.js is built in Preact, so why not take advantage of it?
235+
236+
Usage:
237+
238+
```js
239+
this.cols = [
240+
{
241+
name: 'Actions',
242+
formatter: (cell, row) => {
243+
return this.$gridjs.h('button', {
244+
className: 'py-2 mb-4 px-4 border rounded-md text-white bg-blue-600',
245+
onClick: () => alert(`Editing "${row.cells[0].data}" "${row.cells[1].data}"`)
246+
} 'Edit');
247+
}
248+
},
249+
{ ... },
250+
{ ... }
251+
]
252+
```
253+
254+
#### \$gridjs.html
255+
256+
Renders [HTML in a formatter function](https://gridjs.io/docs/examples/html-cells).
257+
258+
Example:
259+
260+
```js
261+
this.cols = [
262+
{
263+
name: 'Model',
264+
formatter: cell => this.$gridjs.html(`<b>${cell}</b>`)
265+
},
266+
{ ... },
267+
{ ... }
268+
]
269+
```
270+
271+
#### \$gridjs.render
272+
273+
Renders a Vue component. Refer to [Vue documentation](https://vuejs.org/v2/guide/render-function.html#createElement-Arguments) for advanced options.
274+
275+
Usage:
276+
277+
```js
278+
this.$gridjs.render(ref, component, { props }, { options })
279+
```
280+
281+
Example:
282+
283+
```js
284+
import FormatterComponent from './FormatterComponent.vue'
285+
286+
[...]
287+
288+
this.cols = [
289+
{
290+
name: 'Model',
291+
formatter: cell => {
292+
const current = this.$gridjs.uuid()
293+
this.$gridjs.render(
294+
`[data-ref="${current}"]`,
295+
FormatterComponent,
296+
{
297+
content: cell,
298+
otherProp: true
299+
}
300+
)
301+
return this.$gridjs.html(`<div data-ref="${current}"></div>`)
302+
}
303+
},
304+
{ ... },
305+
{ ... }
306+
]
307+
```
308+
309309
## 🤝 Contributing
310310

311311
Originally authored by [Daniel Sieradski](https://twitter.com/self_agency).

0 commit comments

Comments
 (0)