You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Oct 24, 2019. It is now read-only.
*[Getting the root element](#getting-the-root-element)
21
+
*[Static Methods](#static-methods)
22
+
*[Events](#events)
23
+
*[Addons](#addons)
21
24
*[Pull Request Steps](#-pull-request-steps)
22
25
*[Documents](#-documents)
23
26
*[Contributing](#-contributing)
24
27
*[License](#-license)
25
28
26
29
## Collect statistics on the use of open source
27
30
28
-
React Wrapper of TOAST UI Grid applies Google Analytics (GA) to collect statistics on the use of open source, in order to identify how widely TOAST UI Grid is used throughout the world. It also serves as important index to determine the future course of projects. location.hostname (e.g. > “ui.toast.com") is to be collected and the sole purpose is nothing but to measure statistics on the usage. To disable GA, use the following `usageStatistics`option when declare React Wrapper compoent.
31
+
React Wrapper of TOAST UI Grid applies Google Analytics (GA) to collect statistics on the use of open source, in order to identify how widely TOAST UI Grid is used throughout the world. It also serves as important index to determine the future course of projects. location.hostname (e.g. > “ui.toast.com") is to be collected and the sole purpose is nothing but to measure statistics on the usage. To disable GA, use the `usageStatistics`props like the example below.
29
32
30
33
```js
31
-
var options = {
32
-
...
33
-
usageStatistics:false
34
-
}
34
+
<Grid
35
+
data={[/* ... */]}
36
+
columns={[/* ... */]}
37
+
usageStatistics={false}
38
+
/>
35
39
```
36
40
37
41
Or, import `tui-code-snippet.js` (**v1.4.0** or **later**) and then immediately write the options as follows:
[All the options of the TOAST UI Grid](http://nhnent.github.io/tui.grid/latest/Grid) are supported in the form of props.
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.
73
77
74
78
```js
75
79
constdata= [
@@ -84,40 +88,45 @@ const columns = [
84
88
];
85
89
86
90
constMyComponent= () => (
87
-
<Grid
91
+
<Grid
88
92
data={data}
89
93
columns={columns}
90
-
bodyHeight={100}
94
+
rowHeight={25}
95
+
bodyHeight={100}
96
+
virtualScrolling={true}
97
+
heightResizable={true}
98
+
rowHeaders={['rowNum']}
91
99
/>
100
+
92
101
);
93
102
```
94
103
95
104
### Reactive Props
96
105
97
-
Normally, React Components are re-rendered whenever the props received from a parent Component are changed. But not all the props of this Component are reactive as the TOAST UI Grid does not provide setter methods for all options. Below are the list of reactive props which are currently supported.
106
+
Normally, React components are re-rendered whenever the props received from a parent component are changed. But not all the props of the wrapper component are reactive as the TOAST UI Grid does not provide setter methods for all options. Below are the list of reactive props which are currently supported.
If you don't want some props to be reactive, you can disable reactivity of specific props using `oneTimeBindingProps`. For example, if you don't want to re-render whenever `data` and `columns` props are changed, you can use `oneTimeBindingProps` like example below.
113
+
If you don't want some props to be reactive, you can disable reactivity of specific props using `oneTimeBindingProps`. For example, if you don't want to re-render whenever `data` and `columns` props are changed, you can use `oneTimeBindingProps` like the example below.
105
114
106
115
```js
107
-
108
116
constMyComponent= () => (
109
117
<Grid
110
118
data={data}
111
119
columns={columns}
112
120
bodyHeight={100}
121
+
frozenColumnCount={2}
113
122
oneTimeBindingProps={['data', 'columns']}
114
123
/>
115
124
);
116
125
```
117
126
118
-
### Methods (Using Ref)
127
+
### Instance Methods
119
128
120
-
For using methods of TOAST UI Grid instance, first thing to do is creating Refs of wrapper Component using `createRef()`. The wrapper Component does not provide a way to call methods of TOAST UI Grid instance directly. Instead, you can call `getGridInstance()` method of the wrapper Component to get the instance, and call the methods with it.
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 `getGridInstance()` method of the wrapper component to get the instance, and call the methods on it.
121
130
122
131
```js
123
132
classMyComponentextendsReact.Component {
@@ -134,23 +143,92 @@ class MyComponent extends React.Component {
An instance of the wrapper component also provides a handy method for getting the root element. If you want to manipulate the root element directly, you can call `getRootElement` to get the element.
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.
184
+
185
+
```js
186
+
importTuiGridfrom'tui-grid';
187
+
188
+
TuiGrid.setLanguage('ko');
189
+
TuiGrid.applyTheme('striped');
190
+
```
191
+
192
+
### 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.
149
194
195
+
```js
196
+
classMyComponentextendsReact.Component {
197
+
handleClick= () => {
198
+
console.log('click!!');
199
+
}
200
+
201
+
render() {
202
+
return (
203
+
<Grid
204
+
data={data}
205
+
columns={columns}
206
+
onClick={this.handleClick}
207
+
/>
208
+
);
209
+
}
210
+
}
211
+
```
150
212
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 up like the example below.
151
215
152
-
### Event
216
+
```js
217
+
constcolumns= [/* ... */];
218
+
constnetOptions= {
219
+
perPage:10,
220
+
api: {
221
+
readData:'api/readData'
222
+
}
223
+
};
153
224
225
+
constMyComponent= () => (
226
+
<Grid
227
+
columns={columns}
228
+
addOn={{Net: netOptions}}
229
+
/>
230
+
);
231
+
```
154
232
155
233
## 🔧 Pull Request Steps
156
234
@@ -159,7 +237,7 @@ Run npm scripts and develop yourself with the following process.
159
237
160
238
### Setup
161
239
162
-
Fork `develop` branch into your personal repository.
240
+
Fork `master` branch into your personal repository.
163
241
Clone it to local computer. Install node modules.
164
242
Before starting development, you should check to haveany errors.
165
243
@@ -180,9 +258,6 @@ If it has no error, commit and then push it!
180
258
181
259
For more information on PR's step, please see links of Contributing section.
0 commit comments