|
<ejs-tab id="element" #element (selected)="select($event)" (created)=created($event) >
<e-tabitems>
<e-tabitem [header]='headerText[0]' content="#idv"></e-tabitem>
<e-tabitem [header]='headerText[1]' content="#idv" ></e-tabitem>
</e-tabitems>
</ejs-tab>
<div id="idv" >
<router-outlet></router-outlet>
</div>
Ts:
public created(e){
this.tabObj.items.push({ header: { text: 'MyForm' }, content: "#idv" }); // refer the router id
(<any>this.tabObj).refresh();
}
public select(e: any) { //based on the selection index the page will load with the dynamic components in it
if (e.selectedIndex == 0) {// selected index
this.router.navigateByUrl('/home');
}
else if (e.selectedIndex == 1) {
this.router.navigateByUrl('/about');
}
else if (e.selectedIndex == 2) {
this.router.navigateByUrl('/home');
}
}
|
Hi Maged Mikaeeel,Thanks for Contacting Syncfusion support.Based on your requirement of dynamically adding the other components from another form page, we suggest your add them using the Angular <router-outlet> and then load them.
<ejs-tab id="element" #element (selected)="select($event)" (created)=created($event) ><e-tabitems><e-tabitem [header]='headerText[0]' content="#idv"></e-tabitem><e-tabitem [header]='headerText[1]' content="#idv" ></e-tabitem></e-tabitems></ejs-tab><div id="idv" ><router-outlet></router-outlet></div>Ts:public created(e){this.tabObj.items.push({ header: { text: 'MyForm' }, content: "#idv" }); // refer the router id(<any>this.tabObj).refresh();}public select(e: any) { //based on the selection index the page will load with the dynamic components in itif (e.selectedIndex == 0) {// selected indexthis.router.navigateByUrl('/home');}else if (e.selectedIndex == 1) {this.router.navigateByUrl('/about');}else if (e.selectedIndex == 2) {this.router.navigateByUrl('/home');}}You can also load the content dynamically through Ajax also. Please find the below UG link for more reference.Please check our shared sample and if you still have any query means, please let us know so that we would help you out better.Let us know if you have any further queries.Regards,Arun P.
|
//set the content as different divs
<ejs-tab id="element" #element (created)=created($event) >
<e-tabitems>
<e-tabitem [header]='headerText[0]' content="#idv1" ></e-tabitem>
<e-tabitem [header]='headerText[1]' content="#idv2" ></e-tabitem>
</e-tabitems>
</ejs-tab>
//initially set the div display as none
<div id="idv1" style="display:none">
<home></home> //load your page here
</div>
<div id="idv2" style="display:none" >
<about></about>
</div>
<div id="idv3" style="display:none">
<home></home>
</div>
|
Hi Maged Mikaeeel,
Thanks for your update.
Query1:” If I want to open multiple tabs from the same control, for example, the second and third tab should open the home control, and each of them should have different instances and data entered by the user should be different,”
We have validated your query and found that even if we use the same home control for both the Tab items, the instances are different only. Hence the control instances are different on each tab item and wont share the same instances on each. Hence if you feel that our EJ2 components shares the same id on both item, we suggest you to render the component in the home page without a ID. As per our EJ2 base implementation, the components will render with an auto generated ID by default. This is because of the getUniqueId method which is handled in our EJ2 Angular source.
Demo sample: https://stackblitz.com/edit/github-lushmu-yjkn9u?file=src%2Fapp%2Fhome%2Fhome.component.html
Query2:” with this fix it won't work as they share the same instance also moving between the tabs will cause some issues like it will not show the tab contents in some cases!”
You have mentioned that “will cause some issues like it will not show the tab contents in some cases”. So can be more specific about this issue? And can you please explain what are the issues that your facing with this scenario?. Do you have any sample to replicate this issue. If so, please use our shared sample to replicate, so that we would analyze and provide you an prompt solution.
Please check the shared details, sample and let us know if you have any further queries.
Regards,
Arun P.
Hi Maged Mikaeeel,
Thanks for your update.
Query1:” If I want to open multiple tabs from the same control, for example, the second and third tab should open the home control, and each of them should have different instances and data entered by the user should be different,”
We have validated your query and found that even if we use the same home control for both the Tab items, the instances are different only. Hence the control instances are different on each tab item and wont share the same instances on each. Hence if you feel that our EJ2 components shares the same id on both item, we suggest you to render the component in the home page without a ID. As per our EJ2 base implementation, the components will render with an auto generated ID by default. This is because of the getUniqueId method which is handled in our EJ2 Angular source.
Demo sample: https://stackblitz.com/edit/github-lushmu-yjkn9u?file=src%2Fapp%2Fhome%2Fhome.component.html
Query2:” with this fix it won't work as they share the same instance also moving between the tabs will cause some issues like it will not show the tab contents in some cases!”
You have mentioned that “will cause some issues like it will not show the tab contents in some cases”. So can be more specific about this issue? And can you please explain what are the issues that your facing with this scenario?. Do you have any sample to replicate this issue. If so, please use our shared sample to replicate, so that we would analyze and provide you an prompt solution.
Please check the shared details, sample and let us know if you have any further queries.
Regards,
Arun P.