antd 표 줄 클릭 단추 선택 이벤트

7642 단어 웹 개발js
/**
 *      
 *          
 *
 */
export const dealWidthSelectRow = dealData =>{
   const {
      rowKeys,//   key   
      rows,//       
      record//      
   } = dealData;
   let  x = rowKeys.findIndex((value,index)=>{
      return value === record.key
   });
   if(x === -1){
      rowKeys.push(record.key);
      rows.push(record)
   }else{
      delete rowKeys[x];
      delete rows[x]
   }
   TrimSpace(rows);
   TrimSpace(rowKeys);
   return {
      rowKeys:rowKeys,
      rows: rows
   }
};

구성 요소 페이지:
class A extend ...{
  onRowClick = (record, selected, selectedRows, nativeEvent)=>{
   let dealData = {
      rowKeys : this.state.selectedRowKeys,
      rows : this.state.selectRows,
      record : record
   };
   let {rowKeys, rows} = dealWidthSelectRow(dealData);
   console.log(rowKeys);
   console.log(rows);
   this.setState({
      selectedRowKeys:rowKeys,
      okSelectNum: rows.length,
      selectRows: rows
   })
};

render(){
return (
{
let className = null;
if (record.id === '' || record.id === null || record.id === undefined) {
className = 'close_checkbox'
}
return className
}
}
onRow={(record, index) => {
return {
onClick: () => {
this.onRowClick(record, index)
} / / 클릭 줄
}
}}
rowSelection={rowSelection}
columns={this.columns}
dataSource={data}
loading={loading}
onChange={this.handleTableChange}
pagination={{
total: pageTotal,
showQuickJumper:true,
current: pagination.pageNum
}}
/>
)}}  

좋은 웹페이지 즐겨찾기