import React from 'react';
import ReactDOM from 'react-dom';
import Table from '..';
const result = [
    {
        id: '001',
        time: 1951,
        title: { name: 'The Old Man and the Sea' },
    },
    {
        id: '002',
        time: 1925,
        title: { name: 'the great gatsby' },
    },
    {
        id: '003',
        time: 1719,
        title: { name: 'The adventures of Robinson Crusoe' },
    },
];
class Demo extends React.Component {
    constructor() {
        super(...arguments);
        this.state = {
            dataSource: result,
        };
        this.onRemove = id => {
            const { dataSource } = this.state;
            let index = -1;
            dataSource.forEach((item, i) => {
                if (item.id === id) {
                    index = i;
                }
            });
            if (index !== -1) {
                dataSource.splice(index, 1);
                this.setState({
                    dataSource,
                });
            }
        };
        this.renderOper = (value, index, record) => {
            return (React.createElement("a", { onClick: this.onRemove.bind(this, record.id) },
                "Remove(",
                record.id,
                ")"));
        };
    }
    render() {
        return (React.createElement("div", null,
            React.createElement(Table, { dataSource: this.state.dataSource },
                React.createElement(Table.Column, { title: "Id", dataIndex: "id" }),
                React.createElement(Table.Column, { title: "Title", dataIndex: "title.name" }),
                React.createElement(Table.Column, { title: "Time", dataIndex: "time" }),
                React.createElement(Table.Column, { title: "operate", cell: this.renderOper }))));
    }
}
ReactDOM.render(React.createElement(Demo, null), document.getElementById('table-demo-26'));
