This repository was archived by the owner on Feb 6, 2024. It is now read-only.
forked from glittershark/reactable
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathtr.jsx
More file actions
47 lines (39 loc) · 1.54 KB
/
tr.jsx
File metadata and controls
47 lines (39 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import React from 'react';
import { Td } from './td';
import { toArray } from './lib/to_array';
import { filterPropsFrom } from './lib/filter_props_from';
export class Tr extends React.Component {
render() {
var children = toArray(React.Children.children(this.props.children));
const {className} = this.props
if (
this.props.data &&
this.props.columns &&
typeof this.props.columns.map === 'function'
) {
if (typeof(children.concat) === 'undefined') { console.log(children); }
children = children.concat(this.props.columns.map(function(column, i) {
if (this.props.data.hasOwnProperty(column.key)) {
var value = this.props.data[column.key];
var props = {};
if (
typeof(value) !== 'undefined' &&
value !== null &&
value.__reactableMeta === true
) {
props = value.props;
value = value.value;
}
return <Td column={column} key={column.key} {...props}>{value}</Td>;
} else {
return <Td column={column} key={column.key} />;
}
}.bind(this)));
}
// Manually transfer props
var {i, ...props} = filterPropsFrom(this.props);
return React.DOM.tr(props, children);
}
};
Tr.childNode = Td;
Tr.dataType = 'object';