I'm trying to add button to each row in fixed data table, but I don't know how. My current code:
var Details = React.createClass({
getInitialState() {
return {
rows: usersStore.getUsersList(),
filteredRows: null,
filterBy: null,
};
},
componentWillMount() {
this._filterRowsBy(this.state.filterBy);
},
_rowGetter(rowIndex) {
return this.state.filteredRows[rowIndex];
},
_filterRowsBy(filterBy) {
var rows = this.state.rows.slice();
var filteredRows = filterBy ? rows.filter(function(row){
return row.name.toLowerCase().indexOf(filterBy.toLowerCase()) >= 0
}) : rows;
this.setState({
filteredRows,
filterBy,
});
},
_onFilterChange(e) {
this._filterRowsBy(e.target.value);
},
render: function () {
return (
<div>
<label>filter by <input onChange={this._onFilterChange} /></label>
<Table
height={200}
rowHeight={30}
rowGetter={this._rowGetter}
rowsCount={this.state.filteredRows.length}
width={450}
maxHeight={450}
headerHeight={40}>
<Column
label="Name"
width={270}
dataKey="name"
/>
<Column
label="Age"
width={100}
dataKey="age"
/>
<Column
label="Qualification"
width={120}
dataKey="Qualification"
/>
<Column label="Edit"
width={120}>
<button type="button" className="btn btn-default" onClick={this.update}>Update</button>
</Column>
</Table>
</div>
);
}
})
While using this code it showing datakey is mandatory and if I remove column tags and adding only button in table also its not accepting.