Edit this page

Initialize Grids in TabStrips

The example below demonstrates how to use the activate event when initializing the Grid within the TabStrip so as it is resized according to the dimensions of its container.

Important

In addition to the Kendo UI TabStrip, this example can be applied to the PanelBar and Window widgets, which, too, act as hidden containers for the Grid.

Example
     <body>
      <button id="openBtn">Open</button>

      <div id="tabstrip">
        <ul>
          <li id="tab1">Tab 1</li>
          <li id="tab2">Tab 2</li>
        </ul>
        <div><div id="grid"></div></div>
        <div>Content 2</div>
      </div>

      <script src="https://demos.telerik.com/kendo-ui/content/shared/js/products.js"></script>
      <script>
        var tabstrip = $("#tabstrip").kendoTabStrip().data("kendoTabStrip");

        var grid = $("#grid").kendoGrid({
            dataSource: {
              data: products,
              pageSize: 5
          },
          height: 200,
          scrollable: true,
          columns: [
              "ProductName",
              { field: "UnitPrice", title: "Unit Price", format: "{0:c}", width: "130px" },
              { field: "UnitsInStock", title: "Units In Stock", width: "130px" },
              { field: "Discontinued", width: "130px" }
            ]
          }).data("kendoGrid");

          //apply the activate event, which is thrown only after the animation is played out
          tabstrip.one("activate", function() {
            grid.resize();
          });

          $("#openBtn").click(function(e) {
            tabstrip.activateTab($("#tab1"));
          });
        </script>
    </body>

See Also

Other articles and how-to examples related to the Kendo UI TabStrip:

For more runnable examples on the Kendo UI TabStrip widget, browse its How To documentation folder.

Is this article helpful? Yes / No
Thank you for your feedback!

Give article feedback

Tell us how we can improve this article

close
Dummy