TabView, dynamically add TabPanel

UI Components for React
Post Reply
Hanland
Posts: 24
Joined: 07 Jan 2018, 14:12

11 Jan 2018, 13:04

Hi, very new to primereact,

Is it possible to programmatically add a new TabPanel to a TabView, or would you just iterate through a list with the panel added and re-render the page?

Is it possible to programmatically select a TabPanel and bring it to the front, or would this be done in a similar way to the above?

Regards

merve7
Posts: 861
Joined: 12 Sep 2017, 10:44

26 Feb 2018, 13:02

1.No, It is not possible to programmatically add a new TabPanel to a TabView.
2.Yes, It is possible to programmatically select a TabPanel with activeIndex property.

Code: Select all

constructor() {
        super();
        this.state = {
            activeIndex:0
        };
    }
    ...
    ...
    <Button onClick={()=>this.setState({activeIndex:2})}/>
    <TabView activeIndex={this.state.activeIndex} onTabChange={(event)=>this.setState({activeIndex:event.index})}>
         <TabPanel header="Godfather I" leftIcon="fa-calendar">
         </TabPanel>
         <TabPanel header="Godfather II" rightIcon="fa-print">
         </TabPanel>
         <TabPanel header="Godfather III" leftIcon="fa-bell-o" rightIcon="fa-bookmark-o"></TabPanel>
         <TabPanel header="Godfather IV" disabled={true}>
         </TabPanel>
   </TabView>

Post Reply

Return to “PrimeReact”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 8 guests