facebookarchive / fixed-data-table

A React table component designed to allow presenting thousands of rows of data.
http://facebook.github.io/fixed-data-table/
Other
4.3k stars 553 forks source link

Is there any way to put a text input into cell? How to get the updated value? #367

Open CrisLi opened 8 years ago

CrisLi commented 8 years ago

I have a simple requirement. A table with some cell can be edited. I can display the cell as input text, but how to get the cell updated values?

I am using react-bootstrap to generate input text. I can't add ref to InputCell since it is stateless function components. Is there any way to make any cell editable?

import { Input } from 'react-bootstrap';

const InputCell = ({rowIndex, field, data, onChange, ...props}) => (
  <Cell {...props}>
    <form>
    <Row>
      <Col xs={8}>
        <Input type="text" bsSize="small" addonBefore="$" defaultValue={data[rowIndex][field]} />
      </Col>
    </Row>
    </form>
  </Cell>
);
vinayaknagpal commented 8 years ago

You can use onChange within Input to trigger an action. Alternatelively you can wrap your form in a stateful conponent and use that inside InputCell.