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

[Solved] ComboBox on Model Window not working for me

2 Answers 148 Views
Window
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Pim
Top achievements
Rank 1
Pim asked on 11 Jan 2011, 11:57 PM
Hello All,

I thought I posted a question about my issue yesterday, but I cannot find it anymore, hence this new topic.

I created a Window that loads the content from a Partial view. On this partial view is a Telerik ComboBox.
When the page Loads with the window on it I get a Javascript Error:

Microsoft JScript runtime error: Object doesn't support this property or method.

This only happens when I have a ComboBox on the Window. When we remove the ComboBox from the Window it opens fine..

The code we use for the Window:
<%= Html.Telerik().Window()
            .Name("DeleteObjectWindow")
            .LoadContentFrom("PopUp", "Home")
            .Buttons(buttons => buttons.Maximize().Close())
            .Width(900)
            .Height(250)
            .Modal(true)
            .Title("Please select item.")
            .Visible(true)
            .Draggable(true)
    %>

The code for the Partial View:
<% using (Html.BeginForm()) %>
<%{%>
<div class="editor-label">
    <%: Html.LabelFor(model => model.Selecteditem) %>
</div>
<div class="editor-label">
    <%: Html.Telerik().ComboBoxFor(model => model.Selecteditem)
         .HighlightFirstMatch(true)
         .BindTo(new SelectList(Model.ListOfSelectItems, "ValueMember", "DisplayMember"))
    %>
</div>
<% } %>

Code for the Controller:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using TelerikMvcApplication1.Models;
 
namespace TelerikMvcApplication1.Controllers
{
    [HandleError]
    public class HomeController : Controller
    {
        public ActionResult Index()
        {
            ViewData["Message"] = "Welcome to ASP.NET MVC!";
 
            return View();
        }
 
        public ActionResult PopUp()
        {
            var testItem = new TestItem();
            return PartialView(testItem);
        }
    }
}

Code for Model:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
 
namespace TelerikMvcApplication1.Models
{
    public class TestItem
    {
        public string Selecteditem { get; set; }
 
        public List<SelectItem> ListOfSelectItems
        {
            get
            {
                var listOfItems = new List<SelectItem>();
                listOfItems.Add(new SelectItem(){DisplayMember = "One", ValueMember = "1"});
                listOfItems.Add(new SelectItem(){DisplayMember = "Two", ValueMember = "2"});
                listOfItems.Add(new SelectItem(){DisplayMember = "Three", ValueMember = "3"});
                listOfItems.Add(new SelectItem(){DisplayMember = "Four", ValueMember = "4"});
 
                return listOfItems;
            }
        }
    }
    public class SelectItem
    {
        public string DisplayMember{get;set;}
        public string ValueMember{get;set;}
    }
}


We are using version: 2010.3.1110.

Also please find attached the sample project.

I just followed the code for creating a Window from here: http://demos.telerik.com/aspnet-mvc/window/clientsideapi

What am I doing wrong?
Thanks, once again your help is very much appreciated.

Pim

2 Answers, 1 is accepted

Sort by
0
Hristo Germanov
Telerik team
answered on 12 Jan 2011, 09:17 AM
Hello Pim,

 If you remove "Combined" and "Compress" from ScriptRegistrar in Site.Mater and if you look at in the view page source in the browser you will see that only the window is his registered required files.

 The solution is to check here.

 You need to add:

<% Html.Telerik().ScriptRegistrar().DefaultGroup(group =>
     {
         group.Add("telerik.common.min.js");
         group.Add("telerik.list.min.js");
         group.Add("telerik.combobox.min.js");
     });
%>
this piece of code in your "Index.aspx" page. 


Greetings,
Hristo Germanov
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items
0
Pim
Top achievements
Rank 1
answered on 13 Jan 2011, 01:34 AM
Thanks for that.
I found that page earlier, I noticed I do have all the required files, but wasn't aware I had to register those files explicitly.

Cheers!
Tags
Window
Asked by
Pim
Top achievements
Rank 1
Answers by
Hristo Germanov
Telerik team
Pim
Top achievements
Rank 1
Share this question
or