将实例值绑定到onchange方法

时间:2017-09-20 11:06:26

标签: reactjs

getTd(objectKeys,rowobj,mykey,klist,trcname){
        console.log(rowobj)
        var mcolname="";
        var ab = objectKeys.map((colname,key)=>{
            if(this.showCol(colname)){
                var cname =this.state.className+colname; 
                mcolname=rowobj[colname];
                switch (colname){
                    case '' : 
                        return (<td id = {mykey+colname} className = {cname} ><button>Submit</button></td>)
                    case 'Admin_Approve':
                        return (
                            <td>
                                <div className="ph-switch">
                                  <span>Deals</span>
                                 <input type="checkbox" defaultChecked = {this.ischecked(mcolname)} id="id-name--1" name="set-name" className="switch-input" onChange={()=>this.updateCheckbox(rowobj)} />
                                  <label htmlFor="id-name--1" className="switch-label"></label>
                                  <span>Mandates</span>
                                </div>
                            </td>)
                    default:
                        return( <td id = {mykey+colname}  className={cname}>{mcolname}</td>);
                } //end of switch
            }//end of excludedcolumns
        });
        return(<tr id={"tr"+mykey+rowobj["User_Pk"]} 
                  className={trcname}
                  >
            {ab}{klist}
            </tr>)
    }

var valTd = tableData.map((rowobj,key)=>{ //iterating thro the rows
    var mykey=rowobj[objectKeys[1]]; //gets the subdealkey
     var rows=[];


    vlist=this.getColArray(objectKeys,colArray,mykey,rows,mlist);


    return ( <tbody id={"body"+mykey}>{rows} </tbody> )
    });

我有这个多次调用的getTd函数,但在这里我有map函数。我希望每个rowObj值与map函数内的onchange方法绑定。 目前它绑定到第一个rowObj值

我的onchange方法总是打印传递的第一个rowObj

updateCheckbox =(rowobj)=>{
    console.log(rowobj)
}

1 个答案:

答案 0 :(得分:0)

问题在于交换机的ID

while IFS= read -r -d '' file; do
  echo "$file"|grep "$stream"|rev|cut -d'_' -f2|rev|sort|tail -1
done < <(find "$streamPath" -maxdepth 1 -type f -name '*.zip' -print0)