ej.Tab.prototype._tabDeleteClick = function (args) {
if (this.model.enabled) {
var currentTab = $(args.target);
if (currentTab.closest("li").hasClass("e-active") && currentTab.hasClass("e-close")){
$(this.contentPanels[this.model.selectedItemIndex()]).html("");
}
}
}; |
// Inputs need to be in the following format to be resolved properly let inputProviders = Object.keys(inputData).map((inputName) => {return {provide: inputName, useValue: inputData[inputName]};}); let resolvedInputs = ReflectiveInjector.resolve(inputProviders); // We create an injector out of the data we want to pass down and this components injector let injector = ReflectiveInjector.fromResolvedProviders(resolvedInputs, vcRef.parentInjector); // We create a factory out of the component we want to create let factory = this.resolver.resolveComponentFactory(component); // We create the component using the factory and the injector let comp = factory.create(injector); // We insert the component into the dom container vcRef.insert(comp.hostView); this.tabComponents[tabId] = comp; |
Here is your asked working sample (which has some bugs, for instance - can't change title when tab reused). Just bear in mind, my provided sample is kinda working, but it's not right. I'm looking for better, easier and cleaner solution. My main goal is to be able dynamically create tabs and then add into them my custom created ng2 components. Not Syncfusion component, but my custom created component (which might have syncfusion component). You should understand what I need by checking sample out.P.S. Node_Modules folder excluded because of the file size, but I added it here: http://www74.zippyshare.com/v/xnoKpJXp/file.html
tabObj["contentPanels"][tabCount].innerHTML = "<div #" + tabId +"></div>";
|
onHide(args)
{
var tabObj = this.gpTabPanel.widget;
var tabLi = tabObj["element"]["find"]("li");
tabObj["hideItem"](1);
tabObj["items"][1]["setAttribute"]("style","display:none;");
tabLi[tabObj["items"]["length"]-1]["parentNode"]["append"](tabLi[1]);
}
//In the above method, we are hiding the second tab item and displaying it in last position |
Hey,
I tried to implement your solution, but I get weird behavior: After moving old tab to the back of the row, on mouse over a tab it sets 'Exit' button visibility for the previous tab (check picture):
After I add new tab normally, it fixed 'X' button visibility issues, bu then it shows two active tabs at the same time:
Any solution?
Moreover, after you close those two new tabs and create new one, some of the old dissapears until you again, create a few more new tabs and then everything seems to work ok.
Checked your provided sample, has same bugs.
onHide(args)
{
var tabObj = this.gpTabPanel.widget;
var tabLi = tabObj["element"]["find"]("li");
if(tabObj["items"]["length"]<=1){
alert("Add more Tabs");
}else{
tabObj["hideItem"](1);
tabObj["items"][1]["setAttribute"]("style","display:none;");
tabLi[tabObj["items"]["length"]-1]["parentNode"]["append"](tabLi[1]);
tabObj["_itemsRefreshing"]();
tabObj["items"]["parent"]()["find"](".e-active")["trigger"]("click");
}
}
onShow(args)
{
var tabObj = this.gpTabPanel.widget;
var tabLi = tabObj["element"]["find"]("li");
if(tabObj["items"]["length"]<=1){
alert("Add more Tabs");
}else{
tabObj["showItem"](1);
tabObj["items"][1]["removeAttribute"]("style");
tabObj["_itemsRefreshing"]();
tabObj["items"]["parent"]()["find"](".e-active")["trigger"]("click");
}
} |
Hey,
Your provided code is working, but after that two code-rows is executed, content gets mixed up. Checked tab and content Ids - everything is fine (see image), but visually wrong content is shown. If your provided code is commented out, content shows fine, but there are those bugs with tabs then. Any solution?
If I comment out your provided code (see image below), content won't mix up and is shown fine. You can test it by commenting out provided code in two places: createNewTab and onBeforeTabItemRemvove.
You can reproduce bug by following these steps:
1. Create 4 tabs (GridComponent, GridComponentA, GridComponentB, GridComponentC)
2. Close 2 ar 3 of them (Don't close Home tab, that one is not implemented - it will stay open all the time)
3. Create closed tabs again. (If tab with that component is already opened, it will be automatically focused, otherwise created and moved to the back).
P.S. I attached working sample.
Once again, to clarify problem: after code (which updates tab items internally) is executed, wrong content is shown within tabs. This won't happen if I don't execute your provided code. Tabs has correct content ids, so this is not a case. You should easily see that in my provided sample, as every grid has different headers by letter (A, B,C or none).
// Showing tab
tabObj["showItem"](tabId);
tabObj["items"][tabId]["removeAttribute"]("style");
//this.myTabPanel.widget.showItem(htId);
//this.myTabPanel.widget.element.ejTab({hiddenItemIndex: this.hiddenTabs });
// Moving tab to the back of tabs row
tabElements[tabId]["parentNode"]["append"](tabToShow);
// Refreshing tabs
tabObj["_itemsRefreshing"]();
tabObj["items"]["parent"]()["find"](".e-active")["trigger"]("click");
tabObj["_refresh"]();
|
Cheers - that works! Looks like we are almost there.. A few more questions:
1. After 'X' is clicked on tab and onBeforeTabRemove() method is executed, how can I focus last tab in a tab row? showItem() seems not to be working...
2. That code you provided me, is there any documentation on that I can look into?
var tabObj = this.myTabPanel.widget.element.ejTab("instance");
tabObj["setModel"]({ selectedItemIndex : tabObj["items"]["length"] - 1}); //To select the last tab
|
Hey,
Your provided code is not working. Something else is missing again?
//selecting the last tab item after hiding
setTimeout(()=>{
tabObj["setModel"]({ selectedItemIndex : tabObj["items"]["length"] - 1});
},1);
|