Kendo

  • UI Framework
  • Mobile
  • Demos
  • Roadmap
  • What's New
  • Download

Skin

  • Framework
  • UI Widgets
  • Integration

    Configuration API Functions
    • /
    Click here to open the window.
    • Description
    • View Code
    • Configuration (10)
    • Methods (10)
    • Events (6)

    The Window widget displays content in a modal or non-modal HTML window. By default, Windows can be moved, resized, and closed by users. Window content can also be defined with either static HTML or loaded dynamically with Ajax.

    A Window can be initialized from virtually any HTML element. During initialization, the targeted content will automatically be wrapped in the Window’s HTML div element.

    Getting Started

    Create a simple HTML element with the Window content

     <p id="window">
         Kendo window content
     </p>

    Initialize Window using a jQuery selector

    $("#window").kendoWindow();

    When a Window is initialized, it will automatically be displayed open near the location of the HTML element that was used to initialize the content.

    Configuring Window behaviors

    Window provides many configuration options that can be easily set during initialization. Among the properties that can be controlled:

    • Minimum height/width
    • Available user Window actions (close/refresh/maximize)
    • Window title
    • Draggable and Resizable behaviors

    Create modal Window with all user actions enabled

     $("#window").kendoWindow({
         draggable: false,
         resizable: false,
         width: "500px",
         height: "300px",
         title: "Modal Window",
         modal: true,
         actions: ["Refresh", "Maximize", "Close"]
     });

    The order of the values in the actions array determines the order in which the action buttons will be rendered in the Window title bar. The maximize action serves both as a button for expanding the Window to fill the screen and as a button to restore the Window to the previous size.

    Positioning and Opening the Window

    In some scenarios, it is preferable to center a Window rather than open it near the HTML element used to define the content. It’s also common to open a Window as the result of an action rather than on initial page load. The Window API provides methods for handling this and many more advanced Window scenarios. Please see the Window demo Methods tab for more details.

    Centering a Window and opening on button click

     <!-- Create Window HTML and a button to open Window -->
     <p id="window">
         Centered Kendo UI Window content
     </p>
     <button id="btnOpen">Open Window</button>

     //Initialize Window, center, and configure button click action-->
     $(document).ready(function(){
         var window = $("#window").kendoWindow({
         title: "Centered Window",
         width: "200px",
         height: "200px",
         visible: false
     }).data("kendoWindow");
     });
     $("#btnOpen").click(function(){
         var window = $("#window").data("kendoWindow");
         window.center();
         window.open();
     });

    Loading Window content with Ajax

    While any valid technique for loading Ajax content can be used, Window provides built-in support for asynchronously loading content from a URL. This URL should return a HTML fragment that can be loaded in a Window content area.

    Load Window content asynchronously

     <!-- Define a basic HTML element for the Window -->
     <div id="window"></div>

     //Initialize and configure to load content async -->
     $(document).ready(function(){
         $("#window").kendoWindow({
           title: "Async Window Content",
           contentUrl: "html-content-snippet.html"
         });
     });
    No code
    actions: Array(default: "Close")
    The buttons for interacting with the window. Predefined array values are "Close", "Refresh", "Minimize", "Maximize".
    animation: Object
    A collection of {Animation} objects, used to change default animations. A value of false will disable all animations in the component.
    close: Animation
    The animation that will be used when the window closes.
    open: Animation
    The animation that will be used when the window opens.
    contentUrl: String
    Specifies a URL that the window should load its content from. For remote URLs, a container iframe element is automatically created.
    draggable: Boolean(default: true)
    Specifies whether the users may move the window.
    minHeight: Integer(default: 50)
    The minimum height that may be achieved by resizing the window.
    minWidth: Integer(default: 50)
    The minimum width that may be achieved by resizing the window.
    modal: Boolean(default: false)
    Specifies whether the window should block interaction with other page elements.
    resizable: Boolean(default: true)
    Specifies whether the users may to resize the window.
    title: String
    The text in the window title bar.
    visible: Boolean(default: true)
    Specifies whether the window will be initially visible.
    • center ()
      Centers the window within the viewport.

      Example

      var wnd = $("#window").data("kendoWindow");
      wnd.center();
    • close ()
      Closes the window

      Example

      var wnd = $("#window").data("kendoWindow");
      wnd.close();
    • content (content)
      Sets/gets the window content.

      Example

      var wnd = $("#window").data("kendoWindow");
      // get the content
      var content = wnd.content();
      // set the content
      wnd.content("

      New content

      ");

      Parameters

      content: String
      The new window content
    • destroy ()
      Destroys the window and its modal overlay, if necessary. Useful for removing modal windows.
    • maximize (e)
      Maximizes a window so that it fills the entire screen.

      Parameters

      e
    • open ()
      Opens the window

      Example

      var wnd = $("#window").data("kendoWindow");
      wnd.open();
    • refresh (url, data)
      Refreshes the window content from a remote url.

      Parameters

      url: String
      The URL that the window should be refreshed from. If omitted, the window content is refreshed from the contentUrl that was supplied upon the window creation.
      data: Object
      Data to be sent to the server.
    • restore ()
      Restores a maximized window to its previous size.
    • title (title)
      Sets/gets the window title.

      Example

      var wnd = $("#window").data("kendoWindow");
      // get the title
      var title = wnd.title();
      // set the title
      wnd.title("New title");

      Parameters

      title: String
      The new window title
    • toggleMaximization (e)
      Toggles the window between a maximized and restored state.

      Parameters

      e
    activate
    Fires when the window has finished its opening animation
    close
    Fires when the window is being closed (by the user or through the close() method)
    error
    Fires when an AJAX request for content fails.
    open
    Fires when the window is opened (i.e. the open() method is called).
    refresh
    Fires when the window contents have been refreshed through AJAX.
    resize
    Fires when the window has been resized by the user.
    • Home
    • UI Framework
    • Mobile
    • Demos
    • Roadmap
    • What's New
    • Blogs
    • Forums
    • Documentation
    • FAQ
    • About
    • Follow us on Twitter
    • Subscribe to our RSS feed

    Kendo UI is powered by Telerik

    Copyright © 2011 Telerik Inc. All rights reserved.