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

kendo mvc window Object doesn't support property or method 'open'

2 Answers 185 Views
Window
This is a migrated thread and some comments may be shown as answers.
Randy
Top achievements
Rank 1
Randy asked on 17 Jun 2016, 09:39 PM

I am trying to open a kendo window based on input from a form. I am getting this error:

JavaScript runtime error: Object doesn't support property or method 'open'

The error occurs when win.open(); is called in the JavaScript in the view as listed below. Any help would be great.

Here is my controller:

using Kendo.Mvc.UI;
using Kendo.Mvc.Extensions;
using KendoGridAjaxBinding.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
 
namespace KendoGridAjaxBinding.Controllers
{
    public class HomeController : Controller
    {
        public ActionResult Index()
        {
            TheModel m = new TheModel();
 
            return View(m);
        }
 
        public ActionResult Search( TheModel m)
        {
            if (m.Name != string.Empty)
            {
                ViewData["OpenGrid"] = "OpenGrid";
            }
            return View("Index", m);
        }
 
    }
}

Here is my view:

@using System
@using System.Web
@using System.Web.Mvc
@using System.Web.Razor
@using Kendo.Mvc.UI
@using KendoGridAjaxBinding.Models
 
@model TheModel
 
@using (Html.BeginForm("Search", "Home", FormMethod.Post, new { @class = "form-horizontal", role = "form" }))
{
    <label for="textinput">Name</label>@Html.TextBoxFor(model => model.Name, new { @class = "input-xs form-control", placeholder = "Name", type = "text" })<br />
    <label for="textinput">Address</label>@Html.TextBoxFor(model => model.Address, new { @class = "input-xs form-control", placeholder = "Address", type = "text" })<br />
    <label for="textinput">City</label>@Html.TextBoxFor(model => model.City, new { @class = "input-xs form-control", placeholder = "City", type = "text" })<br />
    <label for="textinput">State</label>@Html.TextBoxFor(model => model.State, new { @class = "input-xs form-control", placeholder = "State", type = "text" })<br />
    <button id="Search" class="btn btn-primary">Search</button>
}
 
 
 
@(Html.Kendo().Window()
    .Name("window")
    .Width(630)
    .Height(315)
    .Draggable()
    .Resizable()
    .Title("Test Test Test")
    .Actions(actions => actions.Pin().Refresh().Maximize().Close())
    .Visible(false)
)
 
<script type="text/javascript">
    var messageX = '@ViewData["OpenGrid"]';
    if (messageX = "OpenGrid")
    {
        $("#window").kendoWindow();
        var win = $("#window").data("kendoWindow");
 
        var win = $("#window")
        if (win != null)
        {
            win.open();
        }
    }
 
</script>

The Model:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
 
namespace KendoGridAjaxBinding.Models
{
    public class TheModel
    {
        public string Name { get; set; }
        public string Address { get; set; }
        public string City { get; set; }
        public string State { get; set; }
    }
}

Thanks in advance,

rstinson

2 Answers, 1 is accepted

Sort by
0
Accepted
Bozhidar
Telerik team
answered on 21 Jun 2016, 08:19 AM
Hello,

Thanks for contacting Telerik support.

I tested your code and updated it a little in order to call in a proper way the open method:

@(Html.Kendo().Window()
    .Name("window")
    .Width(630)
    .Height(315)
    .Draggable()
    .Resizable()
    .Title("Test Test Test")
    .Actions(actions => actions.Pin().Refresh().Maximize().Close())
    .Visible(false)
)
 
<script type="text/javascript">
    $(document).ready(function() {
            $("#window").kendoWindow();
            var win=$("#window").data("kendoWindow");
            if(win!=null) {
                win.open();
            }
    });
</script>

In the bellow code, i shown what is removed, as you do not need to set the var for a second time:

var win = $("#window").data("kendoWindow");
  
        var win = $("#window")

And also, the same behavior  run in dojo: http://dojo.telerik.com/iPEtA/2

Regards,
Bozhidar
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Randy
Top achievements
Rank 1
answered on 21 Jun 2016, 02:14 PM

That got it. I should have seen that. I think I was looking at it to long to see clearly.

 

Many thanks!!!

Tags
Window
Asked by
Randy
Top achievements
Rank 1
Answers by
Bozhidar
Telerik team
Randy
Top achievements
Rank 1
Share this question
or