tui-grid
Version:
TOAST UI Grid : Powerful data grid control supported by TOAST UI
85 lines (65 loc) • 3.04 kB
Markdown
The TOAST UI Grid provides you an easy way to customize the style of the grid. With `applyTheme()` method, you can easily change entire styles of the grid.
### Using Built-in Presets
There are three built-in presets in the TOAST UI Grid - **default**, **striped** and **clean**. To apply one of these presets, you only have to add one line of code to your source code:
```javascript
tui.Grid.applyTheme('default');
```
If you run the code above or don't apply any preset, the **default** preset will be applied. It looks like below.

Using the **striped** preset adds zebra-striping to the table.
```javascript
tui.Grid.applyTheme('striped');
```
The result will looks like this:

If you want more clean and basic style, use the **clean** preset.
```javascript
tui.Grid.applyTheme('clean');
```
It has a very simple design like below.

### Customizing themes
If you want to apply your own styles to the grid, you can extend the preset theme with your own options. The `applyTheme()` method has a second parameter, which extends the existing theme options. For example, if you want to use **striped** preset with changing the background colors of head-cells and cells in even rows, you can use the code below.
```javascript
tui.Grid.applyTheme('striped', {
cell: {
head: {
background: '#eef'
},
evenRow: {
background: '#fee'
}
}
});
```
The result will looks like this:

The following example extends the **default** preset with the custom options. The options are the same with the **clean** preset. You can see the result by comparing the **default** and the **clean** preset in the screenshots above.
```javascript
tui.Grid.applyTheme('default',
grid: {
border: '#e0e0e0'
},
toolbar: {
border: '#e0e0e0'
},
cell: {
normal: {
background: '#fff',
border: '#e0e0e0',
showVerticalBorder: false,
showHorizontalBorder: true
},
head: {
background: '#fff',
border: '#e0e0e0'
},
selectedHead: {
background: '#e0e0e0'
}
}
});
```
You can see all available options at the `tui.Grid.applyTheme()` section of the [API page](http://nhnent.github.io/tui.grid/api).
### Example page
You can apply preset themes and customize them with a sample grid [here](http://nhnent.github.io/tui.grid/api/tutorial-example07-applying-themes.html).