【问题标题】:React Bootstrap Table - recognising a rowReact Bootstrap Table - 识别一行
【发布时间】:2018-10-14 23:04:10
【问题描述】:

所以我正在从这样的结果集中处理一个可编辑的表格:

data = [
{id: 1, name: 'bob', value: '2'},
{id: 2, name: 'HelloWorld', value: '5'},
{id: 3, name: 'TestName', value: '4'}
];

我的表格是这样的(我还使用自定义编辑器来编辑名称和值):

<BootstrapTable data={this.props.data}>
      <TableHeaderColumn isKey dataField='id'>
        ID
      </TableHeaderColumn>
      <TableHeaderColumn dataField="name" dataFormat= { CustomInputFormatter }
      customEditor={ { getElement : CustomInputEditor } } >
        Name
      </TableHeaderColumn>
      <TableHeaderColumn dataField="value" dataFormat= { CustomInputFormatter }
      customEditor={ { getElement : CustomInputEditor } } >
        Profile
      </TableHeaderColumn>
    </BootstrapTable>

所以我想知道,如果我将名称“TestName”更改为其他名称,是否有办法从 onchange 函数中获取同一行的 ID 和值?

这是 customInputEditor 类的渲染

render() {
let { value } = this.state;
let { type } = this.props;
return (
  <div>
    <input type={type || 'text'} ref="inputRef" className="form-control custom-textbox" value={value}
        onChange={this.onChange} onBlur={this.onBlur}/>
  </div>
);

}

【问题讨论】:

    标签: reactjs bootstrap-table


    【解决方案1】:

    不确定你的 onChange 函数是什么样的,但你应该能够像这样访问这些值:

    onChange = (event) => {
        console.log(event.target.id)
        console.log(event.target.value)
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-03-07
      • 2021-09-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-01-07
      • 1970-01-01
      相关资源
      最近更新 更多