# Initialize the Grid in the Window

## Environment

<table>
 <tr>
  <td>Product</td>
  <td>Progress® Kendo UI® Window for jQuery</td>
 </tr>
 <tr>
  <td>Operating System</td>
  <td>Windows 10 64bit</td>
 </tr>
 <tr>
  <td>Visual Studio Version</td>
  <td>Visual Studio 2017</td>
 </tr>
 <tr>
  <td>Preferred Language</td>
  <td>JavaScript</td>
 </tr>
</table>

## Description

How can I initialize the Kendo UI for jQuery Grid in a Kendo UI for jQuery Window?

## Solution

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

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

```dojo
      <button id="openBtn">Open</button>
      <div id="wnd">
        <div id="grid"></div>
      </div>
      <script src="https://demos.telerik.com/kendo-ui/content/shared/js/products.js"></script>
      <script>
  	    var wnd = $("#wnd").kendoWindow({
          height: 400,
          width: 600,
          visible: false
        }).data("kendoWindow");

        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
          wnd.one("activate", function() { // can use also 'bind' method as Kendo widgets support the "one" and "bind"
                grid.resize();
          });

          $("#openBtn").click(function(e) {
                wnd.open();
          });
        </script>
```

## See Also

* [Initialize the Grid inside a Hidden Container](https://www.telerik.com/kendo-jquery-ui/documentation/web/grid/appearance#initialize-the-grid-inside-a-hidden-container)
* [JavaScript API Reference: Configuration of Window Animations](https://www.telerik.com/kendo-jquery-ui/documentation/api/ui/window/configuration/animation)
* [Window JavaScript Window API Reference](https://www.telerik.com/kendo-jquery-ui/documentation/api/ui/window)
* [Add Auto-Resizing Splitter](https://www.telerik.com/kendo-jquery-ui/documentation/knowledge-base/add-auto-resizing-splitter)
* [Create Confirmation Dialog via Promises](https://www.telerik.com/kendo-jquery-ui/documentation/knowledge-base/confirmation-dialog-promise)
* [Display Loading Indicator over Window](https://www.telerik.com/kendo-jquery-ui/documentation/knowledge-base/display-loading-overlay)
* [Use Custom Action Icons](https://www.telerik.com/kendo-jquery-ui/documentation/knowledge-base/use-custom-action-icons)
