EasyUI Forum
February 22, 2020, 11:50:27 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: I can't select last TAB page programmatically. Alyways first tab being selected  (Read 183 times)
spider58
Newbie
*
Posts: 32


View Profile
« on: February 12, 2020, 07:21:05 AM »

Hi,

I using TAB component on react.

I have some TAB pages and i want to select last tab page as "selected"

i tried below code

Code:
this.mytabs.map ((tab, index) => {

     return index == this.mytabs.length() ? <TabPanel selected index...... id..... key ..........><TabContainer>bla</TabContainer></TabPanel> :
<TabPanel index...... id..... key ..........><TabContainer>bla</TabContainer></TabPanel>
                         

})
As you can see i only add SELECTED into last TAB. But unfortunatelly first tab is beling selected on program startup.
Logged
jarry
Administrator
Hero Member
*****
Posts: 1783


View Profile Email
« Reply #1 on: February 14, 2020, 08:03:46 PM »

Please set the 'selectedIndex' value to change the 'selected' state for your tab panels.
Code:
<Tabs
    ref={el => this.tabsRef = el}
    selectedIndex={this.state.selectedIndex}
    onTabSelect={(panel) => {
        const selectedIndex = this.tabsRef.getPanelIndex(panel);
        this.setState({ selectedIndex })
    }}
>
...
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!