diff --git a/demo/demolist/Demo0501.js b/demo/demolist/Demo0501.js index b1e523d..b38ba32 100644 --- a/demo/demolist/Demo0501.js +++ b/demo/demolist/Demo0501.js @@ -5,82 +5,96 @@ * @description 可以对行进行编辑的表格 * demo0501 */ -import React, { Component, PureComponent } from "react"; +import React, { Component } from "react"; import Table from "../../src"; import { Select, Form, FormControl, Button, Icon, Tooltip } from "tinper-bee"; const Option = Select.Option; import { RefTreeWithInput } from "ref-tree"; -function handleFormValueChange(WarpCompProps, field, allFields) { - const { onChange, throwError } = WarpCompProps; - if (field.value === "") return throwError && throwError(true); - throwError && throwError(false); - onChange && onChange(field.value); -} +class StringEditCell extends Component { + constructor(props, context) { + super(props); + this.state = { + value: props.value + }; + } -const StringEditCell = Form.createForm({ - onValuesChange: handleFormValueChange -})(PureStringEditCell); + componentWillReceiveProps(nextProps) { + if (!nextProps.editable) { + this.setState({ value: nextProps.value }); + } + } -function PureStringEditCell(props) { - const { getFieldProps, getFieldError } = props.form; - const { value, editable, required } = props; - let cls = "editable-cell-input-wrapper"; - if (required) cls += " required"; - if (getFieldError("value")) cls += " verify-cell"; - return editable ? ( -