ZBLOG

/* eslint-disable no-shadow */ import React, { Component, PropTypes } from 'react'; import { connect } from 'react-redux'; import { Table } from 'antd'; import * as actions from 'common/modules/productCenter/instanceManagement'; import { data } fr...

根据你提供的代码,你想在表格中选择一行数据,并在选择后执行下一步操作。你可以按照以下方式修改代码:

  1. ControlInformation组件的constructor方法中,添加一个新的状态变量selectedRowKey,用于存储选中行的creditLimitNodeInstanceCode:
constructor(props) {
  super(props);
  this.state = {
    limitCode: '', // 当前选中节点
    selectedRowKey: '' // 新增的状态变量
  };
}
  1. 在render方法中,将rowSelection对象中的onSelect回调函数修改如下,更新选中行的creditLimitNodeInstanceCode并设置到state中:
onSelect: (selectRow) => {
  console.log(selectRow);
  this.setState({
    selectedRowKey: selectRow.creditLimitNodeInstanceCode
  });
}
  1. 修改render方法末尾处ButtonGroup组件内按钮的onClick事件处理函数,检查是否选择了行数据。如果没有选择,则弹出提示框;否则执行相应操作。
<Button bsStyle="primary" onClick={() => {
  if (!this.state.selectedRowKey) {
    alert('请先选择一行数据');
    return;
  }
  staging(this.props.fields);
}}>
  暂存
</Button>
<Button bsStyle="primary" onClick={handleSubmit}>
  下一步
</Button>

通过以上修改,当用户没有选择任何行数据时,在点击”暂存”按钮或”下一步”按钮时会弹出一个提示框提醒用户先进行选择。请注意,在代码其他部分可能还需要做一些适应性的调整,以确保修改能够正确地与其他代码协同工作。


内容由零声教学AI助手提供,问题来源于学员提问

本站部分文章来源于网络,版权归原作者所有,如有侵权请联系站长删除。
转载请注明出处:http://sdn.0voice.com/?id=2442

分享:
扫描分享到社交APP
上一篇
下一篇
发表列表
游客 游客
此处应有掌声~
评论列表

还没有评论,快来说点什么吧~

联系我们

在线咨询: 点击这里给我发消息

微信号:3007537140

上班时间: 10:30-22:30

关注我们
x

注册

已经有帐号?