We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Don't show tab content when we remove a tab and then add it again

Thread ID:

Created:

Updated:

Platform:

Replies:

148829 Nov 5,2019 08:29 PM UTC Feb 3,2020 10:16 AM UTC Blazor 6
loading
Tags: Tabs
ebi torabi
Asked On November 5, 2019 08:29 PM UTC

Hi.
Please look at the attachment

@page "/"

<EjsTab @ref="sourceTab" CssClass="e-fill" EnableRtl="true" OverflowMode="OverflowMode.Scrollable" HeightAdjustMode="HeightStyles.None" Height="390px" ShowCloseButton="false">
    <TabEvents></TabEvents>
    <TabItems @ref="@TabItems1">

        <TabItem @ref="@a">
            <ChildContent>
                <TabHeader Text="aaaaaaa"></TabHeader>
            </ChildContent>

            <ContentTemplate>
                <p>aaaaaaa</p>
            </ContentTemplate>
        </TabItem>
        <TabItem @ref="@b">
            <ChildContent>
                <TabHeader Text="bbbbbbbbb"></TabHeader>
            </ChildContent>

            <ContentTemplate>
                <p>bbbbb</p>
            </ContentTemplate>
        </TabItem>
        <TabItem @ref="@c">
            <ChildContent>
                <TabHeader Text="cccccccccccc"></TabHeader>
            </ChildContent>

            <ContentTemplate>
                <p>cccccccccccccc</p>
            </ContentTemplate>
        </TabItem>

    </TabItems>
</EjsTab>
<EjsButton ID="NextButton1" @onclick="@add" IsPrimary="true" Content="add"></EjsButton>
<EjsButton ID="NextButton" @onclick="@remove" IsPrimary="true" Content="remove"></EjsButton>
<EjsButton ID="NextButton111" @onclick="@next" IsPrimary="true" Content="next"></EjsButton>
<EjsButton ID="NextButton1212" @onclick="@back" IsPrimary="true" Content="back"></EjsButton>
@code{
    EjsTab sourceTab;
    TabItem a;
    TabItem b;
    TabItem c;
    TabItems TabItems1;
    EjsSlider<double> PregnancyAgeSlider;
    List<TabItem> f = new List<TabItem>();
    List<TabItem> Removed = new List<TabItem>();
    public void add(Microsoft.AspNetCore.Components.Web.MouseEventArgs args)
    {
        if (Removed.Contains(b))
        {
            if (!f.Contains(b))
            {

                f.Add(b);

                sourceTab.AddTab(f, 1);

                Removed.Remove(b);
            }
        }
    }
    public void remove(Microsoft.AspNetCore.Components.Web.MouseEventArgs args)
    {

        if (!Removed.Contains(b))
        {
            Removed.Add(b);

            f.Remove(b);
            sourceTab.RemoveTab(sourceTab.Items.IndexOf(b));
        }
    }
    public void next(Microsoft.AspNetCore.Components.Web.MouseEventArgs args)
    {
        int s = Convert.ToInt32(sourceTab.SelectedItem);
        sourceTab.Select(s + 1);
    }
    public void back(Microsoft.AspNetCore.Components.Web.MouseEventArgs args)
    {
        int s = Convert.ToInt32(sourceTab.SelectedItem);
        sourceTab.Select(s - 1);
    }
}


Attachment: tabProblem_b1f26730.rar

Nevitha Ravi [Syncfusion]
Replied On November 6, 2019 12:06 PM UTC

Hi Ebi, 

Greetings from Syncfusion Support. 

The cause for the reported problem is that currently it is not feasible to add the tab item dynamically whose content is provided in content template. We have already logged a feature request for this requirement which can be tracked from the following link.  


The feature will be implemented and included in our Volume 4 main release which is expected to be rolled out in the month of December 2019.  

Meanwhile, you can achieve your requirement by providing the content as string or assign the content of tab items dynamically before adding the tab item, please find the modified code snippet. 

@using Syncfusion.EJ2.Blazor.Navigations 
@using Syncfusion.EJ2.Blazor.Buttons 
 
 
<EjsTab @ref="sourceTab" CssClass="e-fill" EnableRtl="true" OverflowMode="OverflowMode.Scrollable" HeightAdjustMode="HeightStyles.None" Height="390px" ShowCloseButton="false"> 
    <TabEvents></TabEvents> 
    <TabItems @ref="@TabItems1"> 
        <TabItem @ref="@a"> 
            <ChildContent> 
                <TabHeader Text="aaaaaaa"></TabHeader> 
            </ChildContent> 
            <ContentTemplate> 
                  <p>@AContent</p> 
            </ContentTemplate> 
        </TabItem> 
        <TabItem @ref="@b" Content="bbbbbbb"> 
            <ChildContent> 
                <TabHeader Text="bbbbbbbbb"></TabHeader> 
            </ChildContent> 
            <ContentTemplate> 
                  <p>@BContent</p> 
            </ContentTemplate> 
        </TabItem> 
        <TabItem @ref="@c" Content="cccccc"> 
            <ChildContent> 
                <TabHeader Text="cccccccccccc"></TabHeader> 
            </ChildContent> 
            <ContentTemplate> 
                  <p>@CContent</p> 
            </ContentTemplate> 
        </TabItem> 
 
    </TabItems> 
</EjsTab> 
<EjsButton ID="NextButton1" @onclick="@add" IsPrimary="true" Content="add"></EjsButton> 
<EjsButton ID="NextButton" @onclick="@remove" IsPrimary="true" Content="remove"></EjsButton> 
<EjsButton ID="NextButton111" @onclick="@next" IsPrimary="true" Content="next"></EjsButton> 
<EjsButton ID="NextButton1212" @onclick="@back" IsPrimary="true" Content="back"></EjsButton> 
 
@code{ 
    EjsTab sourceTab; 
    TabItem a; 
    TabItem b; 
    TabItem c; 
    TabItems TabItems1; 
    List<TabItem> f = new List<TabItem>(); 
    List<TabItem> Removed = new List<TabItem>(); 
    string BContent = "bbbbbbbbbb"; 
    string AContent = "aaaaaaa"; 
    string CContent = "cccccccccccccc"; 
    public void add(Microsoft.AspNetCore.Components.Web.MouseEventArgs args) 
    { 
        if (Removed.Contains(b)) 
        { 
            if (!f.Contains(b)) 
            { 
                                 b.Content = BContent; 
                a.Content = AContent; 
                c.Content = CContent; 
                f.Add(b); 
                sourceTab.AddTab(f, 1); 
                Removed.Remove(b); 
            } 
        } 
     } 
     public void remove(Microsoft.AspNetCore.Components.Web.MouseEventArgs args) 
     { 
        if (!Removed.Contains(b)) 
        { 
            Removed.Add(b); 
            f.Remove(b); 
            sourceTab.RemoveTab(sourceTab.Items.IndexOf(b)); 
        } 
    } 
      public void next(Microsoft.AspNetCore.Components.Web.MouseEventArgs args) 
      { 
            int s = Convert.ToInt32(sourceTab.SelectedItem); 
            sourceTab.Select(s + 1); 
      } 
      public void back(Microsoft.AspNetCore.Components.Web.MouseEventArgs args) 
      { 
            int s = Convert.ToInt32(sourceTab.SelectedItem); 
            sourceTab.Select(s - 1); 
       } 
  } 


Please keep in touch with us if you need any further assistance. 

Regards, 
Nevitha. 


ebi torabi
Replied On November 6, 2019 12:18 PM UTC

Hi Nevitha.

But this problem also occurs when our content is one or more components, that's how the problem is solved
If you know of another way to remove or add a tab to the wizard, please share with me.

Nevitha Ravi [Syncfusion]
Replied On November 7, 2019 11:32 AM UTC

Hi Ebi, 

Sorry for the inconvenience caused. 

We can add or remove a tab item using the AddTab and RemoveTab public methods. You can achieve your requirement using these methods with v17.3.17 release version. We have prepared a sample for the same which can be downloaded from the following link. 

<head> 
    <meta charset="utf-8" /> 
    <meta name="viewport" content="width=device-width, initial-scale=1.0" /> 
    <title>RenderTab</title> 
    <base rel='nofollow' href="~/" /> 
    <link rel="stylesheet" rel='nofollow' href="css/bootstrap/bootstrap.min.css" /> 
    <link rel='nofollow' href="css/site.css" rel="stylesheet" /> 
    <link rel='nofollow' href="https://cdn.syncfusion.com/ej2/17.3.17/material.css" rel="stylesheet" /> 
</head> 

We have a breaking issue with latest release version, so your shared code is not working properly with latest release. The issue fix will be included in our next bi-weekly patch release which is scheduled to rolled out on mid of November, 2019. The bug can be tracked from the following link: 

Regards, 
Nevitha. 


Alagumeena Kalaiselvan [Syncfusion]
Replied On January 27, 2020 02:48 PM UTC

Hi Ebi, 

Sorry for the delay to get back to you! 

Query 1:  How to add tab items dynamically through ContentTemplate? 

We have provided the feature “Dynamically add tab items through ContentTemplate” and included with our 2019 Volume 4 main release which is promised.  

Refer to the below release notes. 

Query 2:  Breaking Issue 

Also, We have resolved the breaking issue “Content disappears when dynamically add the tab” and included with our patch release. 

Refer to the below release notes. 

We will happy to assist you if you need further assistance. 

Regards 
Alagumeena.K 


ebi torabi
Replied On February 1, 2020 06:44 AM UTC

Hi Alagumeena.K .Thank you very much. 

Alagumeena Kalaiselvan [Syncfusion]
Replied On February 3, 2020 10:16 AM UTC

Hi Ebi, 

You are most welcome! 

Regards 
Alagumeena.K 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon