EasyUI Forum

General Category => EasyUI for React => Topic started by: spider58 on February 12, 2020, 07:21:05 AM



Title: I can't select last TAB page programmatically. Alyways first tab being selected
Post by: spider58 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.


Title: Re: I can't select last TAB page programmatically. Alyways first tab being selected
Post by: jarry 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 })
    }}
>
...