Skip to content

Commit

Permalink
fixed heading when hiding elements
Browse files Browse the repository at this point in the history
  • Loading branch information
zackify committed Sep 24, 2015
1 parent 42dad57 commit ebcd486
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-legit-table",
"version": "0.4.1",
"version": "0.4.2",
"description": "the simplest table component out there",
"main": "lib/table.js",
"scripts": {
Expand Down
15 changes: 10 additions & 5 deletions src/head.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,16 @@ export default class Head extends React.Component{
}

headings() {
return Object.keys(this.props.row).map((name) => {
if(this.props.hide){
let result = this.props.hide.map(ignore => ignore === name)
if(result) return true
}
let row = Object.assign({}, this.props.row)
if (this.props.hide) {
this.props.hide.map(ignore => {
Object.keys(this.props.row).map(key => {
if(key === ignore) delete row[key]
})
})
}

return Object.keys(row).map((name) => {
return <th key={uniqueId(name)}>{this.props.capitalize ? this.titleize(name) : name}</th>;
});
}
Expand Down

0 comments on commit ebcd486

Please sign in to comment.