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. Image for the cookie policy date
close icon

Grid inside Tab

Can you add a Grid inside a Tab?

3 Replies

DL Deepa Loganathan Syncfusion Team October 26, 2018 11:18 AM UTC

Hi Dave,  
 
Thanks for contacting Syncfusion support.  
 
Yes, you can add Grid control as a content of Tab as given in the below code.  
 
 
ViewBag.content1 = "#RemoteData"; // Set the content of Tab as Grid ID in indexpage 
            ViewBag.content2 = "Content 2"; 
            ViewBag.content3 = "Content 3"; 
            ViewBag.content4 = "Content 4"; 
 
            List<TabTabItem> headerItems = new List<TabTabItem>(); 
 
            headerItems.Add(new TabTabItem { Header = new TabHeader { Text = "Grid"}, Content = ViewBag.content1 }); 
            headerItems.Add(new TabTabItem { Header = new TabHeader { Text = "Header2" }, Content = ViewBag.content2}); 
            headerItems.Add(new TabTabItem { Header = new TabHeader { Text = "Header3" }, Content = ViewBag.content3}); 
            headerItems.Add(new TabTabItem { Header = new TabHeader { Text = "Header4" }, Content = ViewBag.content4 }); 
 
            ViewBag.headeritems = headerItems; 
 

We have prepared a sample based on your requirement and is available for download in the following link.  


Please check and get back to us if you need any further assistance.  

Regards,  
Deepa L. 



DN Dave Nixon October 27, 2018 03:18 AM UTC

If you move to the second tab it shows until you select the second tab and move off.

public ActionResult Index()
{
    ViewBag.content1 = "Content 1";
    ViewBag.content2 = "#RemoteData";
    ViewBag.content3 = "Content 3";
    ViewBag.content4 = "Content 4";
    List<TabTabItem> headerItems = new List<TabTabItem>();
    headerItems.Add(new TabTabItem { Header = new TabHeader { Text = "Header1" }, Content = ViewBag.content1 });
    headerItems.Add(new TabTabItem { Header = new TabHeader { Text = "Grid" }, Content = ViewBag.content2 });
    headerItems.Add(new TabTabItem { Header = new TabHeader { Text = "Header3" }, Content = ViewBag.content3 });
    headerItems.Add(new TabTabItem { Header = new TabHeader { Text = "Header4" }, Content = ViewBag.content4 });
    ViewBag.headeritems = headerItems;
    return View();
}



DL Deepa Loganathan Syncfusion Team October 29, 2018 11:56 AM UTC

Hi Dave, 
 
 
Thanks for the update.  
 
 
We have analyzed the reported issue and we would like to let you know that this is the default behavior of Tab component. So, if the content is passed as ID to the Tab item, it will be initially available in the view page (i.e. the HTML) and will be removed from the body element only while selecting the respective Tab item. 
 
 
So, to resolve this issue, you would need to set the visibility of targeted content element as hidden in the view page as given below 
.  
 

Index.cshtml 

   <div id="griddata" style="display:none">   // set display as none 
       @Html.EJS().Grid("RemoteData").DataSource(..).Render()  
      </div> 
     

  
In addition to this, you could add items dynamically to the tab by using the addTab method in the selecting event of Tab component. This way you could prevent the content from being initially displayed in the view page. Please refer our below help page to know more about the options available in Tab.  
 
 
 
 
Please let us know if you need any further assistance on this. 
 
 
Regards,  
 
Deepa L. 


Loader.
Live Chat Icon For mobile
Up arrow icon