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

Custom editing - binding dropdownlist to a grid cell

4 Answers 635 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Shabtai
Top achievements
Rank 1
Shabtai asked on 02 May 2013, 09:10 AM
Hi

I'm trying to reproduce the custom editing sample with dropdownlist inside the gridcell.
For some reason, the combo is not created...

I'm attaching the project to this message.

Do I miss any script for the project?

Thank you in advance,
Shabtai

4 Answers, 1 is accepted

Sort by
0
Accepted
Atanas Korchev
Telerik team
answered on 06 May 2013, 07:24 AM
Hi,

 Which custom editing example are you trying to reproduce? We currently don't see any dropdownlist or combobox code in your project. 

 I recommend checking the following resources:
 - The editor templates help topic - explains how to create a custom editor template for a model property
 - The Kendo UI for ASP.NET MVC sample application. There is a custom editing demo:

           Kendo.Mvc.Examples\Areas\razor\Views\web\grid\editing_custom.cshtml
           Kendo.Mvc.Examples\Areas\razor\Views\web\grid\EditorTemplates\ClientCategory.cshtml
           Kendo.Mvc.Examples\Areas\razor\Views\web\grid\EditorTemplates\ClientEmployee.cshtml

Regards,
Atanas Korchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Shabtai
Top achievements
Rank 1
answered on 06 May 2013, 09:13 AM
Thank you so much for the reply!

Pity there's no mentioning of client templates in the online sample:

http://demos.kendoui.com/web/grid/editing-custom.html

Besides, the functionality of grid (addition, editing...) doesn't work for me if the key column contains zero (0).
0
Tim
Top achievements
Rank 1
answered on 17 Mar 2015, 11:47 AM
Hi All,

I am trying to bind Dropdown in one of the columns for the incell editor Kendo Grid.
I am not sure where I am going wrong, probably some basic mistake. 

I have a Main View Page with the Editable Grid, Another view page to populate the dropdown in cell.
The cell in the main grid is not populating as a dropdown list, basically it is not firing the dropdown view page.
I am not really sure where I am going wrong, probably I am doing some basic mistake.

MasterDataLookup.cshtml:

  @using (Html.BeginForm("ReplaySelectedMessages", "Home"))
     {
        <div id="gridContent">
       <h1></h1>  
    @(Html.Kendo().Grid<ViaPath.LookUpDataManagement.MvcApp.Models.MasterDataMappingModel>(Model)
    .Name("gridTable")    
    .HtmlAttributes(new { style = "font-family: verdana,arial,sans-serif; font-size: 11px;color: #333333;border-color: #999999;" })
    .Columns(columns =>
    {
        columns.Bound(p => p.ClientAppName).ClientTemplate("# try {# #=ClientAppName# #} catch (e) {}#").EditorTemplateName("ComboBoxLookup").Width(200);
        //columns.ForeignKey(p => p.ClientAppName, (System.Collections.IEnumerable)ViewData["ClientsApplications"], "ClientAppId", "ClientAppName");
        columns.Bound(p => p.SupplierAppName).Width(200);
        columns.Bound(p => p.ListName).Width(200);
        columns.Bound(p => p.ClientValueName).Width(200);
        columns.Bound(p => p.SupplierValueName).Width(200);
        columns.Bound(p => p.Direction).Width(200);
        columns.Command(command =>  {
                command.Edit();
                command.Destroy();
            }).Width(200);
       
    })
            .ToolBar(t => t.Create())
            .Editable(editable => editable.Mode(GridEditMode.InLine))
            .Filterable(e => e.Extra(false))
            .Pageable(page => page.PageSizes(new int[] { 10, 25, 50, 100 }).Enabled(true))
            .Sortable()
            .Scrollable(src => src.Height("auto"))
            .Resizable(resize => resize.Columns(true))
            .DataSource(
                source => source
                    .Ajax() 
                    .ServerOperation(true)                  
                    .Model(model =>
                {
                    model.Id(e => e.MasterDataMappingId);
                    model.Field(e => e.MasterDataMappingId).Editable(false);
                    //model.Field(e => e.ClientAppName).Editable(true);
                    model.Field(p => p.ClientAppName).DefaultValue(
                ViewData["defaultApplications"] as ViaPath.LookUpDataManagement.MvcApp.Models.MasterDataMappingModel);
                    
                })
                .Create(create => create.Action("Create_MasterDataMapping", "Home"))
                .Read(read => read.Action("Read_MasterDataMapping", "Home"))
                 .Update(update => update.Action("Update_MasterDataMapping", "Home"))
                 .Destroy(destroy => destroy.Action("Destroy_MasterDataMapping", "Home")))
                 
            // .ClientDetailTemplateId("MasterDataListTemplate")
            // .ToClientTemplate()
             
            )


ComboBoxLookup.cshtml

@model IEnumerable<ViaPath.LookUpDataManagement.MvcApp.Models.ApplicationsModel>    

@using ViaPath.LookUpDataManagement.MvcApp




@(Html.Kendo().DropDownListFor(m => m)
        .Name("ComboBoxLookup")
        .DataValueField("AppId")
        .DataTextField("ApplicationName")
        .BindTo((System.Collections.IEnumerable)ViewData["Applications"])
)

Controller.cs

 public ActionResult MasterDataLookUp()
        {        
            List<MasterDataMappingModel> masterDataMappings = null;
            masterDataMappings = GetMasterDataMapping();

            ViewData["Applications"] = masterDataMappings.Select(p => new
            {
                ClientAppId = p.ClientAppId,
                ClientAppName = p.ClientAppName

            }).Distinct();

            ViewData["defaultApplications"] = masterDataMappings.Select(p => new
            {
                ClientAppId = p.ClientAppId,
                ClientAppName = p.ClientAppName

            }).First();

          

            return View(masterDataMappings);
        }
0
Vladimir Iliev
Telerik team
answered on 19 Mar 2015, 09:40 AM
Hi Dino,

I would suggest to make sure the editor template is nested inside the "EditorTemplates" folder as mentioned in the following help article:

If the editor template is correctly placed and still not loading - could you please open a new support ticket or forum post and provide runable example where the issue is reproduced? This would help us pinpoint the exact reason for current behavior.

Regards,
Vladimir Iliev
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Grid
Asked by
Shabtai
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Shabtai
Top achievements
Rank 1
Tim
Top achievements
Rank 1
Vladimir Iliev
Telerik team
Share this question
or