js react 全选和反选

Posted 北野

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了js react 全选和反选相关的知识,希望对你有一定的参考价值。

onCheckAll = (data) => {
		var CheckBox  = document.getElementsByName(data);
		for(let i=0;i<CheckBox.length;i++){
            if(CheckBox[i].checked==true){
                     CheckBox[i].checked=false;
            } else{
                 CheckBox[i].checked=true
            }
        };
	}



const columnWBS = [
			{title:‘WBS节点名称‘,dataIndex:‘label‘},
			{title:‘权限‘,dataIndex:‘qx‘,
			render: (text, record, index) =>(
		      	<span >
			      	<Button size="small" onClick={this.onCheckAll.bind(this,record.key)} style={{marginRight:‘5px‘}}> 全选</Button>
			      	<span id="checkBoxWrap">
				      	<input type="checkbox"  name={record.key} style={{marginLeft:‘5px‘}}/> 添加
				      	<input type="checkbox"  name={record.key} style={{marginLeft:‘5px‘}}/> 删除
				      	<input type="checkbox"  name={record.key} style={{marginLeft:‘5px‘}}/> 编辑
				      	<input type="checkbox"  name={record.key} style={{marginLeft:‘5px‘}}/> 查看
				    </span>
		      	</span>
			
			)}]

  

以上是关于js react 全选和反选的主要内容,如果未能解决你的问题,请参考以下文章