如何将复选框添加到 react bootstrap table2 header 单元格中的单元格?
how to add checkbox to cells in react bootstrap table2 header cells?
我正在使用 react-bootstrap-table-next 并想将 "checboxes" 添加到某些 header 单元格中。我参考了文档 - 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}/>
}
}
header 个单元格中复选框的预期输出 -
我使用 "headerFormatter" 自定义了 header 个单元格。下面是工作代码和输出截图
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 });
}
我正在使用 react-bootstrap-table-next 并想将 "checboxes" 添加到某些 header 单元格中。我参考了文档 - 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}/>
}
}
header 个单元格中复选框的预期输出 -
我使用 "headerFormatter" 自定义了 header 个单元格。下面是工作代码和输出截图
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 });
}