# Initialize the Grid in a TabStrip

## Environment

<table>
 <tr>
  <td>Product</td>
  <td>Telerik UI for ASP.NET MVC Grid and Telerik UI for ASP.NET MVC TabStrip</td>
 </tr>
 <tr>
  <td>Progress Telerik UI for ASP.NET MVC version</td>
  <td>Created with the 2024.2.514 version</td>
 </tr>
</table>

## Description

How can I display the Grid component in a specified tab of a TabStrip?

By design, when the Grid is initialized inside a hidden container, its layout may not be resized correctly. For example, when the Grid is integrated into the TabStrip component, the Grid initializes when the respective tab activates. For more information, refer to the [Grid in hidden containers article](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/data-management/grid/appearance/hidden-containers).

## Solution

> You can apply the same approach when integrating the Grid into a PanelBar or Window components, which also act as hidden containers for the Grid.

1. Handle the `Activate` event of the TabStrip.
2. Get a reference to the Grid and call the [`resize()`](https://docs.telerik.com/kendo-ui/api/kendo/methods/resize) method when the Grid becomes visible.

   ```Razor HtmlHelper
       @(Html.Kendo().TabStrip()
           .Name("tabStrip")
           .Events(e => e.Activate("onActivate"))
           ... // Other configuration.
       )
   ```

   ```JS scripts
   <script type="text/javascript">
       function onActivate(e) {
           let activatedTab = $(e.item).attr("id"); // Get the "id" of the activated tab.
           if (activatedTab == "tabStrip-tab-2") { // For example, if the Grid is defined in the second tab, check if the tab is activated.
               $("#grid").getKendoGrid().resize(true); // Resize the Grid to fit the tab's container.
           }
       }
   </script>
   ```

For a runnable example based on the code above, refer to the [REPL example on displaying a Grid in a TabStrip component](https://netcorerepl.telerik.com/GIEhQebf12x2kz7200).

## More ASP.NET MVC Grid Resources

* [ASP.NET MVC Grid Documentation](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/data-management/grid/overview)

* [ASP.NET MVC Grid Demos](https://demos.telerik.com/aspnet-mvc/grid/index)

* [ASP.NET MVC Grid Product Page](https://www.telerik.com/aspnet-mvc/grid)

* [Telerik UI for ASP.NET MVC Video Onboarding Course (Free for trial users and license holders)](https://www.telerik.com/aspnet-mvc/documentation/getting-started/video-onboarding)

* [Telerik UI for ASP.NET MVC Forums](https://www.telerik.com/forums/aspnet-mvc)

## See Also

* [Client-Side API Reference of the Grid for ASP.NET MVC](https://docs.telerik.com/kendo-ui/api/ui/grid)

* [Server-Side API Reference of the Grid for ASP.NET MVC](https://docs.telerik.com/aspnet-mvc/api/grid)

* [Telerik UI for ASP.NET MVC Breaking Changes](https://www.telerik.com/aspnet-mvc/documentation/backwards-compatibility/2023-backwards-compatibility)

* [Telerik UI for ASP.NET MVC Knowledge Base](https://docs.telerik.com/aspnet-mvc/knowledge-base)
