我正在使用react-bootstrap-table-next,并想将“ checboxes”添加到某些标题单元格中。我参考了文档https://react-bootstrap-table.github.io/react-bootstrap-table2/storybook/index.html?selectedKind=Welcome&selectedStory=react%20bootstrap%20table%202%20&full=0&addons=1&stories=1&panelRight=0&addonPanel=storybook%2Factions%2Factions-panel,但找不到相关示例。谁能帮忙吗?
import BootstrapTable from 'react-bootstrap-table-next';
class Container extends React.Component{
render(){
<BootstrapTable keyField="PartNumber" selectRow={selectRowProp}
data={this.state.data} columns={this.state.columns}/>
}
}
标头单元格中复选框的预期输出-
答案 0 :(得分:0)
我使用“ headerFormatter”来自定义标题单元格。下面是工作代码和输出屏幕截图
state = {
columns: MYResult.ParametricList_Attributes || []
};
componentDidMount(){
const checkbox = (column, colIndex) => {
//console.log(colIndex)
//console.log("column text "+column.text)
if("Part Number"==column.text || "Product Line"==column.text){
return (
<div>
{column.text}
<span><input type="checkbox" name="something" value="" /></span>
</div>
);
}else{
return (
<div>
{column.text}
</div>
)
}
}
const newColumn = this.state.columns.map((column) => {
//console.log("column --"+column.text)
return {...column, headerFormatter: checkbox};
});
//console.log("newColumn --"+newColumn)
this.setState({columns: newColumn });
}