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

Popup edit form DropDownlist

4 Answers 178 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Steve
Top achievements
Rank 1
Steve asked on 21 Dec 2010, 04:20 PM
Hi,

    I'm a newbie with Popup edit form.  I did many search and succeed to hide some fields in edit mode, customize the form, etc.  However, I'm not able to show a DropDownList in the popup window.  When I add it, the popup form does not display correctly. 

Here is the EditorTemplate for UniteAdministrative.ascx :
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<dynamic>" %>
  
<%
    var controlName = ViewData.TemplateInfo.GetFullHtmlFieldName(String.Empty);
    Html.Telerik().DropDownList().Name(controlName).DataBinding(binding => 
    
        binding.Ajax().Select("_FillUniteAdmDropDownList", "Members"); 
    })
    .Render();
      
%>

Here is the controller code:
[Authorize]
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult _FillUniteAdmDropDownList(string text)
{
    var unites = _container.GetUnitesAdmLight();
    if (text.HasValue())
        unites = unites.Where(u => u.Nom.StartsWith(text));
    return new JsonResult { Data = new SelectList(unites.ToList(), "Pk", "Nom") };
 }

Here is the column in Model:
    [Required]
    [DisplayName("Admin unit")]
    [UIHint("UniteAdministrative")]
public int fk_Unite_UniteAdm {get;set;}

Thank you
Steve

4 Answers, 1 is accepted

Sort by
0
Accepted
Makoto
Top achievements
Rank 1
answered on 21 Dec 2010, 05:10 PM
Since your drop down list is in a partial view, I think you may have to manually add the JavaScript file references for the drop down control.

You can see what files you need to include here:
http://www.telerik.com/help/aspnet-mvc/telerik-ui-components-required-javascript-files.html

DropDownList
  1. jquery-1.4.3.min.js
  2. telerik.common.min.js
  3. telerik.list.min.js
0
Steve
Top achievements
Rank 1
answered on 21 Dec 2010, 10:32 PM
Thank you very much.  it works.  The little remaining problem I have is to select the value from Model.  I tried to copy paste the onedit method I had on another grid bound with Ajax, But with inline editing instead of popup editing and It does not work for me?  Is it supposed to work the same way?  If so, I will continue my search...

Thank you
0
Naveen
Top achievements
Rank 1
answered on 28 Mar 2011, 05:57 PM
I am also facing the same issue. I added the script tag in the partial view still I am having the same error.
0
Vikram
Top achievements
Rank 1
answered on 15 Apr 2011, 05:32 AM
Hi,
  I am not able to get dropdowns in the Pop up when i set the Grid's editing mode to Pop up. 
Also the "Model" in the  partial view  DisplayTemplates\Industry.ascx is throwing object not set to reference exception.


DisplayTemplate\Industry.ascx :

 

 

 

<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<WebApp1.Models.IndustryType>" %>
<%= Html.Encode(Model.IndustryTypeName) %>

PFB the partial view of EditorTemplates\Industry.ascx:

 

 

<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<IndustryType>" %>
<%= Html.Telerik().DropDownList()
        .Name(ViewData.TemplateInfo.GetFullHtmlFieldName(string.Empty))
                            .BindTo(new SelectList((IEnumerable)ViewData["industry"], "IndustryTypeID", "IndustryTypeName", Model == null ? "" : Model.IndustryTypeID.ToString()))
%>

 

 

 

But the same code works perfectly fine when the editing mode of the grid is set to "InLine".

Any help??





 

 

 

 

Tags
Grid
Asked by
Steve
Top achievements
Rank 1
Answers by
Makoto
Top achievements
Rank 1
Steve
Top achievements
Rank 1
Naveen
Top achievements
Rank 1
Vikram
Top achievements
Rank 1
Share this question
or