zoukankan      html  css  js  c++  java
  • react Antdesign Select添加全选功能

    <Form.Item label={`发送对象`}>
    {getFieldDecorator('participants', {
    rules: [{ required: true, message: '请选择发送对象!' }],
    })(
    <Select
    style={{ '300px' }}
    mode="multiple"
    placeholder="请选择"
    onChange={this.selectChange}
    filterOption={(input, option) =>
    option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0
    }
    allowClear
    dropdownRender={allSelectValue => (
    <div onMouseDown={e => e.preventDefault()}>
    <div style={{ padding: '4px 8px 8px 8px', cursor: 'pointer' }}>
    <Checkbox
    checked={this.state.checkStatus}
    onChange={e => this.boxCheck(e)}
    >
    全选
    </Checkbox>
    </div>
    {allSelectValue}
    </div>
    )}
    >
    {this.state.sendList.map((item, index) => {
    return (
    <Option key={index} value={item.partyId}>
    {item.name}
    </Option>
    );
    })}
    </Select>
    )}
    </Form.Item>


    boxCheck = e => {
    this.setState({
    checkStatus: e.target.checked,
    });
    let list = [];
    this.state.sendList.map((item, index) => {
    list.push(item.partyId);
    });
    if (e.target.checked) {
    this.props.form.setFieldsValue({ participants: list });
    } else {
    this.props.form.setFieldsValue({ participants: [] });
    }
    };


  • 相关阅读:
    day59_BOS项目_11
    day58_BOS项目_10
    shell 笔记
    docker + swarm 集群
    HDFS深入浅析
    FTP服务器常规操作
    linux shell 流程控制
    认识黑客常用的入侵方法
    Linux中常用的查看系统信息的命令
    解决Yum安装依赖问题
  • 原文地址:https://www.cnblogs.com/feng3037/p/15325250.html
Copyright © 2011-2022 走看看