This is a migrated thread and some comments may be shown as answers.

How to open a Window from a button

2 Answers 1927 Views
Window
This is a migrated thread and some comments may be shown as answers.
Greg Gum
Top achievements
Rank 1
Greg Gum asked on 12 Dec 2013, 02:01 PM
I have created a window as below.  How do I open this window from a button click?  I have set visible to false so it doesn't show at start up.  How do I then show this window from a button?

@(Html.Kendo().Window()
.Name("kendoWindow") //The name of the window is mandatory. It specifies the "id" attribute of the widget.
.Title("Login") //set the title of the window
.Content(@<text>
This is my window.
</text>)
.Draggable() //Enable dragging of the window
.Resizable() //Enable resizing of the window
.Width(600) //Set width of the window
.Modal(true)
.Visible(true)
)

Greg

2 Answers, 1 is accepted

Sort by
0
Accepted
Alexander Popov
Telerik team
answered on 12 Dec 2013, 02:18 PM
Hi Greg,

Basically when a Window is initialized its Name is used as and ID for the div containing the information about the widget. This allows you to do the following:    
@(Html.Kendo().Window()
.Name("myWindow") //The name of the window is mandatory. It specifies the "id" attribute of the widget.
.Title("Login") //set the title of the window
.Content(@<text>
This is my window.
</text>)
.Draggable() //Enable dragging of the window
.Resizable() //Enable resizing of the window
.Width(600) //Set width of the window
.Modal(true)
.Visible(true)
)
 
<button onclick="openWindow()">Open Window</button>
    
<script>
  function openWindow(){
     var wdw = $("#myWindow").data("kendoWindow"); //get the Window widget's instance
     wdw.open();  //and call its open method
  }
    
</script>

Regards,
Alexander Popov
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Greg Gum
Top achievements
Rank 1
answered on 12 Dec 2013, 04:03 PM
Thank you, this was very helpful.
Tags
Window
Asked by
Greg Gum
Top achievements
Rank 1
Answers by
Alexander Popov
Telerik team
Greg Gum
Top achievements
Rank 1
Share this question
or