码迷,mamicode.com
首页 > 其他好文 > 详细

React 多选框

时间:2020-04-15 10:50:53      阅读:78      评论:0      收藏:0      [点我收藏+]

标签:efault   外网   数据   oca   href   tar   sys   render   text   

if(record.name == this.state.deleteCheckbox[0].name){
console.log(record.name,this.state.deleteCheckbox[0].name,"多选框 和 点击按钮都一样 传哪个值都可以")
}else{
message.error("请点击当前行按钮")
console.log(record.name,this.state.deleteCheckbox[0].name,"请点击当前行按钮")
return;
}

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

if(this.state.location.dataCenter == "全部数据中心"){
this.state.location.dataCenter = 0
}else if(this.state.location.dataCenter == "主数据中心-内网区"){
this.state.location.dataCenter = 1
}else if(this.state.location.dataCenter == "主数据中心-外网区"){
this.state.location.dataCenter = 2
}else{
this.state.location.dataCenter = 3
}

if (this.state.deleteCheckbox.length == 1) {

} else if (this.state.deleteCheckbox.length == 0) {
message.error("请选择一条数据");
} else if (this.state.deleteCheckbox.length > 1) {
message.error("只能选择一条数据");
}

 

if (this.state.deleteCheckbox.length == 1) {
// window.location.href = "#/cloudResource/virtualMachine/SyszLookDetail"
this.state.deleteCheckbox.map((item, index) => {
// var storage = window.sessionStorage;
// storage.setItem("vmDetail", JSON.stringify(item))
this.props.router.push({ pathname : ‘cloudResource/virtualMachine/SyszLookDetail‘ ,state : { name: item} })
console.log(item,"我是虚拟机 查看详情")
})
} else if (this.state.deleteCheckbox.length == 0) {
message.error("请选择一条数据")
} else if (this.state.deleteCheckbox.length > 1) {
message.error("只能选择一条数据")
}

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

render: (text, record) => {
return <Checkbox
onChange={(e) => this.handleCheckbox(e.target.checked, ‘AUTHORITY_ALL‘, text,record)}
// checked={record.AUTHORITY_ALL}
checkd = {true}
value={record.ID}
// indeterminate = {true}
// defaultChecked = {true}
autoFocus = {true}
/>
},

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

{
title: ‘‘,
key: ‘AUTHORITY_ALL‘,
dataIndex: ‘AUTHORITY_ALL‘,
// render: (text, record) => (<Checkbox onChange={this.handleCheckbox} checked={record.AUTHORITY_ALL} value={record.ID} />),
render: (text, record) => (<Checkbox onChange={(e) => this.handleCheckbox(e.target.checked, ‘AUTHORITY_ALL‘, text,record)} checked={record.AUTHORITY_ALL} value={record.ID} />),
},
handleCheckbox=(e,type,id,text,record) => {
console.log(e, type, id,text,record);
}

React 多选框

标签:efault   外网   数据   oca   href   tar   sys   render   text   

原文地址:https://www.cnblogs.com/zhanglanzuopin/p/12703576.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!