Skip to content
This repository was archived by the owner on Oct 24, 2019. It is now read-only.

Commit 71b77b9

Browse files
author
jung-han
committed
Merge branch 'master' into production
2 parents 8025125 + 267cf7e commit 71b77b9

File tree

5 files changed

+3788
-3106
lines changed

5 files changed

+3788
-3106
lines changed

README.md

Lines changed: 44 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# TOAST UI Grid for React
22

3-
> This is a React component wrapping [TOAST UI Grid](https://github.com/nhnent/tui.grid).
3+
> This is a React component wrapping [TOAST UI Grid](https://github.com/nhn/tui.grid).
44
5-
[![github version](https://img.shields.io/github/release/nhnent/toast-ui.react-grid.svg)](https://github.com/nhnent/toast-ui.react-grid/releases/latest)
5+
[![github version](https://img.shields.io/github/release/nhn/toast-ui.react-grid.svg)](https://github.com/nhn/toast-ui.react-grid/releases/latest)
66
[![npm version](https://img.shields.io/npm/v/@toast-ui/react-grid.svg)](https://www.npmjs.com/package/@toast-ui/react-grid)
7-
[![license](https://img.shields.io/github/license/nhnent/toast-ui.react-grid.svg)](https://github.com/nhnent/toast-ui.react-grid/blob/master/LICENSE)
8-
[![PRs welcome](https://img.shields.io/badge/PRs-welcome-ff69b4.svg)](https://github.com/nhnent/toast-ui.react-grid/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22)
9-
[![code with hearth by NHN](https://img.shields.io/badge/%3C%2F%3E%20with%20%E2%99%A5%20by-NHN-ff1414.svg)](https://github.com/nhnent)
7+
[![license](https://img.shields.io/github/license/nhn/toast-ui.react-grid.svg)](https://github.com/nhn/toast-ui.react-grid/blob/master/LICENSE)
8+
[![PRs welcome](https://img.shields.io/badge/PRs-welcome-ff69b4.svg)](https://github.com/nhn/toast-ui.react-grid/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22)
9+
[![code with hearth by NHN](https://img.shields.io/badge/%3C%2F%3E%20with%20%E2%99%A5%20by-NHN-ff1414.svg)](https://github.com/nhn)
1010

1111
## 🚩 Table of Contents
1212
* [Collect statistics on the use of open source](#collect-statistics-on-the-use-of-open-source)
@@ -73,7 +73,7 @@ const Grid = require('@toast-ui/react-grid');
7373

7474
### Props
7575

76-
[All the options of the TOAST UI Grid](http://nhnent.github.io/tui.grid/latest/Grid) are supported in the form of props. Note that `data` and `columns` props are required and other props are optional.
76+
[All the options of the TOAST UI Grid](http://nhn.github.io/tui.grid/latest/Grid) are supported in the form of props. Note that `data` and `columns` props are required and other props are optional.
7777

7878
```js
7979
const data = [
@@ -83,8 +83,8 @@ const data = [
8383
];
8484

8585
const columns = [
86-
{name: 'id', title: 'ID'},
87-
{name: 'name', title: 'Name'}
86+
{name: 'id', header: 'ID'},
87+
{name: 'name', header: 'Name'}
8888
];
8989

9090
const MyComponent = () => (
@@ -126,7 +126,7 @@ const MyComponent = () => (
126126

127127
### Instance Methods
128128

129-
For using [instance methods of TOAST UI Grid](http://nhnent.github.io/tui.grid/latest/Grid#activateFocus), first thing to do is creating Refs of wrapper component using [`createRef()`](https://reactjs.org/docs/refs-and-the-dom.html#creating-refs). But the wrapper component does not provide a way to call instance methods of TOAST UI Grid directly. Instead, you can call `getInstance()` method of the wrapper component to get the instance, and call the methods on it.
129+
For using [instance methods of TOAST UI Grid](http://nhn.github.io/tui.grid/latest/Grid#activateFocus), first thing to do is creating Refs of wrapper component using [`createRef()`](https://reactjs.org/docs/refs-and-the-dom.html#creating-refs). But the wrapper component does not provide a way to call instance methods of TOAST UI Grid directly. Instead, you can call `getInstance()` method of the wrapper component to get the instance, and call the methods on it.
130130

131131
```js
132132
class MyComponent extends React.Component {
@@ -180,7 +180,7 @@ class MyComponent extends React.Component {
180180

181181
### Static Methods
182182

183-
The wrapper component does not provide a way to call [static methods of TOAST UI Grid](http://nhnent.github.io/tui.grid/latest/Grid#applyTheme). If you want to use static methods such as `applyTheme` or `setLanguage` you should use it via importing `tui-grid` directly.
183+
The wrapper component does not provide a way to call [static methods of TOAST UI Grid](http://nhn.github.io/tui.grid/latest/Grid#applyTheme). If you want to use static methods such as `applyTheme` or `setLanguage` you should use it via importing `tui-grid` directly.
184184

185185
```js
186186
import TuiGrid from 'tui-grid';
@@ -190,7 +190,7 @@ TuiGrid.applyTheme('striped');
190190
```
191191

192192
### Events
193-
[All the events of TOAST UI Grid](http://nhnent.github.io/tui.grid/latest/Grid#event-beforeRequest) are supported in the form of `on[EventName]` props. The first letter of each event name should be capitalized. For example, for using `click` event you can use `onClick` prop like the example below.
193+
[All the events of TOAST UI Grid](http://nhn.github.io/tui.grid/latest/Grid#event-beforeRequest) are supported in the form of `on[EventName]` props. The first letter of each event name should be capitalized. For example, for using `click` event you can use `onClick` prop like the example below.
194194

195195
```js
196196
class MyComponent extends React.Component {
@@ -210,26 +210,48 @@ class MyComponent extends React.Component {
210210
}
211211
```
212212

213-
### Addons
214-
TOAST UI Grid uses the **Addon** to extend functionality, which can be setup with the `addon` prop. The `addon` prop recieves an object which conatins the name of the addon as a key, and the option object as a value. For example, if you want to use the [Net addon](https://github.com/nhnent/tui.grid/blob/production/docs/binding-to-remote-data.md#net-add-on) you can set it up like the example below.
213+
### DataSource
214+
In general, the TOAST UI Grid runs on the front-end environment using local data. However, you can also bind remote data using a plain object called `dataSource`. To use this, define the `dataSource` object and set it to the data option like the example below.
215215

216216
```js
217217
const columns = [/* ... */];
218-
const netOptions = {
219-
perPage: 10,
218+
const dataSource = {
219+
withCredentials: false,
220+
initialRequest: true,
220221
api: {
221-
readData: 'api/readData'
222+
readData: {url: 'api/readData', method: 'GET'}
222223
}
223224
};
224225

225226
const MyComponent = () => (
226227
<Grid
227-
columns={columns}
228-
addon={{Net: netOptions}}
228+
columns={columns}
229+
data={dataSource}
230+
pageOptions={{perPage: 3}}
231+
onSuccessResponse={(data) => {
232+
console.log(data);
233+
}}
229234
/>
230235
);
231236
```
232237

238+
### With React Hooks
239+
240+
React Hooks can be used together.
241+
242+
```js
243+
import React, {useCallback} from 'react';
244+
245+
const MyComponentWithHooks = () => {
246+
const onClick = useCallback(() => {
247+
console.log('condition:', condition);
248+
}, [condition]);
249+
250+
return <Grid columns={columns} data={data} onClick={onClick} />;
251+
};
252+
```
253+
254+
233255
## 🔧 Pull Request Steps
234256

235257
TOAST UI products are open source, so you can create a pull request(PR) after you fix issues.
@@ -259,9 +281,9 @@ If it has no error, commit and then push it!
259281
For more information on PR's step, please see links of Contributing section.
260282

261283
## 💬 Contributing
262-
* [Code of Conduct](https://github.com/nhnent/toast-ui.react-grid/blob/master/CODE_OF_CONDUCT.md)
263-
* [Contributing guideline](https://github.com/nhnent/toast-ui.react-grid/blob/master/CONTRIBUTING.md)
264-
* [Commit convention](https://github.com/nhnent/toast-ui.react-grid/blob/master/docs/COMMIT_MESSAGE_CONVENTION.md)
284+
* [Code of Conduct](https://github.com/nhn/toast-ui.react-grid/blob/master/CODE_OF_CONDUCT.md)
285+
* [Contributing guideline](https://github.com/nhn/toast-ui.react-grid/blob/master/CONTRIBUTING.md)
286+
* [Commit convention](https://github.com/nhn/toast-ui.react-grid/blob/master/docs/COMMIT_MESSAGE_CONVENTION.md)
265287

266288
## 📜 License
267-
This software is licensed under the [MIT](./LICENSE) © [NHN.](https://github.com/nhnent)
289+
This software is licensed under the [MIT](./LICENSE) © [NHN.](https://github.com/nhn)

0 commit comments

Comments
 (0)