1
0
mirror of https://github.com/ascribe/onion.git synced 2024-11-15 09:35:10 +01:00
onion/js/components/ascribe_table/table.js

45 lines
1.3 KiB
JavaScript
Raw Normal View History

import React from 'react';
import ReactAddons from 'react/addons';
2015-05-20 14:48:57 +02:00
import TableHeader from './table_header';
import TableColumnContentModel from '../../models/table_column_content_model';
2015-05-20 16:44:45 +02:00
let Table = React.createClass({
2015-05-20 14:48:57 +02:00
propTypes: {
columnList: React.PropTypes.arrayOf(React.PropTypes.instanceOf(TableColumnContentModel)),
2015-06-01 13:18:24 +02:00
changeOrder: React.PropTypes.func
2015-05-20 14:48:57 +02:00
},
renderChildren() {
var that = this;
2015-05-26 13:14:35 +02:00
return ReactAddons.Children.map(this.props.children, (child, i) => {
return ReactAddons.addons.cloneWithProps(child, {
columnList: this.props.columnList,
columnContent: this.props.itemList[i],
key: i
});
});
},
2015-05-22 18:43:15 +02:00
render() {
return (
<div className="ascribe-table">
<TableHeader
columnList={this.props.columnList}
itemList={this.props.itemList}
fetchList={this.props.fetchList}
changeOrder={this.props.changeOrder}
orderAsc={this.props.orderAsc}
orderBy={this.props.orderBy} />
<div className="row">
{this.renderChildren()}
2015-05-20 14:48:57 +02:00
</div>
</div>
);
}
});
2015-05-20 12:00:16 +02:00
export default Table;