EasyUI Forum
April 25, 2024, 07:43:02 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: [SOLVED] CAN'T set Selected linkbutton in Buttongroup  (Read 4718 times)
kifni41
Newbie
*
Posts: 23


View Profile
« on: July 28, 2020, 10:03:09 PM »

Here i want to set as selected if the button meet condidion.
this is the state
Code:
this.state = {
 selectMonth2:6,
 months: [
        {id:1,name:"Jan"}, {id:2,name:"Feb"}, {id:3,name:"Mar"}, {id:4,name:"Apr"}, {id:5,name:"May"}, {id:6,name:"Jun"},
        {id:7,name:"Jul"}, {id:8,name:"Aug"}, {id:9,name:"Sep"}, {id:10,name:"Oct"}, {id:11,name:"Nov"}, {id:12,name:"Dec"}
    ]
}

then i loop button, try to selected if meet condition
Code:
 

<ButtonGroup selectionMode="single">
{this.state.months.map((value,index)=>{
    return <LinkButton style={{width:'35px'}} toggle selected={value.id===this.state.selectMonth2? true : false} key={'xz'+value.id} onClick={()=>{this.setState({selectMonth2: value.id});} }>
               {value.name}
       </LinkButton>
 })}
</ButtonGroup>
 

but can't work, how to set button selected?
« Last Edit: August 05, 2020, 08:36:34 PM by kifni41 » Logged
kifni41
Newbie
*
Posts: 23


View Profile
« Reply #1 on: July 28, 2020, 11:58:16 PM »

ah, so when i try this, remove selectionMode in buttongroup its work

Code:
 <ButtonGroup >
        {this.state.months.map((value,index)=>{
              return <LinkButton style={{width:'35px'}} toggle selected={value.id===this.state.selectMonth2? true : false} key={'xz'+value.id} onClick={()=>{this.setState({selectMonth2: value.id});} }>
               {value.name}
              </LinkButton>

        })}
  </ButtonGroup>

this work fine now, hehe,
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!