Skip to content

Commit

Permalink
Updated documentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
joellanciaux committed Mar 11, 2016
1 parent 998d337 commit 1f0af69
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 3 deletions.
31 changes: 30 additions & 1 deletion docs/src/markdown/customization.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ Griddle parses and evaluates the following columnMetadata object properties:
<dt>customComponent</dt>
<dd><strong>React Component</strong> - The component that should be rendered instead of the standard column data. This component will still be rendered inside of a `TD` element. (more information below in the [Custom Columns section](#customColumns).)</dd>
</dl>
<dl>
<dt>customHeaderComponent</dt>
<dd><strong>React Component</strong> - The component that should be rendered instead of the standard header data. This component will still be rendered inside of a `TH` element. (more information below in the [Custom Columns section](#customColumns).)</dd>
</dl>
<dl>
<dt>customHeaderComponentProps</dt>
<dd><strong>object</strong> - An object containing additional properties that will be passed into the custom header component. (more information below in the [Custom Columns section](#customColumns).)</dd>
</dl>

However, you are also able to pass other properties in as columnMetadata.

Expand Down Expand Up @@ -177,8 +185,17 @@ var LinkComponent = React.createClass({
}
});
```
Additionally, we want the city and state column headers to be highlighted a specific color. We can define a custom header component as:

```
var HeaderComponent = React.createClass({
render: function(){
return <strong style={{color: this.props.color}}>{this.props.displayName}</strong>
}
});
```

From there, we will set the customComponent value in the **name** columnMetadata object to this LinkComponent.
From there, we will set the customComponent value in the **name** columnMetadata object to this LinkComponent. We're also going to update **state** and **city**'s `customHeaderComponent` and `customHeaderComponentProps`.

```
var columnMeta = [
Expand All @@ -190,6 +207,18 @@ var columnMeta = [
"visible": true,
"customComponent": LinkComponent
},
{
...
"columnName": "city",
"customHeaderComponent": HeaderComponent,
"customHeaderComponentProps": { color: 'red' }
},
{
...
"columnName": "state",
"customHeaderComponent": HeaderComponent,
"customHeaderComponentProps": { color: 'blue' }
},
...
];
```
Expand Down
14 changes: 12 additions & 2 deletions examples/customization/customColumn.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@
}
});

var HeaderComponent = React.createClass({
render: function(){
return <strong style={{color: this.props.color}}>{this.props.displayName}</strong>
}
});

var customColumnMetadata = [
{
"columnName": "id",
Expand All @@ -28,13 +34,17 @@
"columnName": "city",
"order": 3,
"locked": false,
"visible": true
"visible": true,
"customHeaderComponent": HeaderComponent,
"customHeaderComponentProps": { color: 'red' }
},
{
"columnName": "state",
"order": 4,
"locked": false,
"visible": true
"visible": true,
"customHeaderComponent": HeaderComponent,
"customHeaderComponentProps": { color: 'blue' }
},
{
"columnName": "country",
Expand Down

0 comments on commit 1f0af69

Please sign in to comment.