EasyUI Forum

General Category => EasyUI for Angular => Topic started by: Swany on January 18, 2018, 11:29:53 AM



Title: How do I select a tab panel component in typescript.
Post by: Swany on January 18, 2018, 11:29:53 AM
How do I select a tab panel component in typescript after the tabs have created. Like from a button click.


Title: Re: How do I select a tab panel component in typescript.
Post by: jarry on January 18, 2018, 04:58:21 PM
Call the 'select' method of TabPanelComponent to select it, or set the 'selectedIndex' of the TabComponent.


Title: Re: How do I select a tab panel component in typescript.
Post by: Swany on January 19, 2018, 09:01:45 AM
Jarry ->I know the documentation say to use those, but I have try both and it is not working. Could you please show me an example so I can see what I am doing wrong?

Let me better explain what I am doing. I am creating a new tab dynamically like your example in https://www.jeasyui.com/forum/index.php?topic=7103.0 (https://www.jeasyui.com/forum/index.php?topic=7103.0). (By the way thank you for that!) The problem I am having is the new tab is not selected after it is created. I need to to automatic select the new tab after it is created.


Title: Re: How do I select a tab panel component in typescript.
Post by: jarry on January 19, 2018, 06:45:10 PM
Please try this code.
Code:
addTab() {
this.tabs.push({
title: 'New Tab',
content: 'New Content'
});
setTimeout(() => this.selectedIndex = this.tabs.length-1);
}


Title: Re: How do I select a tab panel component in typescript.
Post by: Swany on January 23, 2018, 09:57:26 AM
That works, thanks.