Telerik Forums
UI for ASP.NET MVC Forum
0 answers
70 views

I'm using EditorTemple to populate dropdown while in edit mode. I have my editor template in the Views/Shared/EditorTemplates folder.

But when I press the Edit button it does nothing and shows a simple text box instead of a dropdown.

I'm using dynamic properties for binding instead of the view model, all the references I've looked at are based on the view model.

Is there any way to accomplish the same with dynamic property binding?

Here's my code of Grid:


@(Html.Kendo().Grid<object>()
                                        .Name("Grid")
                                        .AutoBind(true)
                                        //.Events(ev => ev.Filter("setGridFilters").DataBound("setAutoFitColumn"))
                                        .Columns(columns =>
                                        {
                                            columns.AutoGenerate(true);
                                            columns.Bound("status").Title("Lead Status").Width(100).EditorTemplateName("LeadStatusList")
                                            .Filterable(a=>a.Multi(true).Search(true).BindTo(new[] {
                                            new{
                                                status="None"
                                            },
                                            new{
                                                status="Initial Call Scheduled"
                                            },
                                            new{
                                                status="Working"
                                            },
                                            new{
                                                status="Nurturing"
                                            },
                                            new{
                                                status="Unqualified"
                                            },
                                            new{
                                                status="Qualified"
                                            }
                                            }));
                                            columns.Bound("ownerId").Title("Owner").Width(100).Filterable(a => a.Multi(true).Search(true).DataSource(ds => ds.Custom()

                                            .Type("aspnetmvc-ajax")
                                            .Transport(transport =>
                                            transport.Read(read => read.Action("", "", new { field = "ownerId" }))
                                            )
                                            .Schema(schema => schema
                                            .Data("names")
                                            )));
                                            columns.Bound("eventBookedC").ClientTemplate("<div   title='#= title #'>#:getEventStatus(eventBookedC) #</div>").Title("Event Booked").Width(70)
                                            .Filterable(a => a.Multi(true).Search(true).BindTo(new[] {
                                            new{
                                                eventBookedC="Null"
                                            },
                                            new{
                                                eventBookedC="True"
                                            },
                                            new{
                                                eventBookedC="False"
                                            }
                                            }));
                                            columns.Command(command => { command.Edit();}).Width(150);
                                        })
                                        .Editable(editable => editable.Mode(GridEditMode.InLine))
                                    .Sortable()
                                    .Filterable()
                                    .Scrollable(sc => sc.Endless(true))
                                    .Groupable()
                                    .Resizable(resize => resize.Columns(true))
                                    .Reorderable(reorder => reorder.Columns(true))

                                    .ToolBar(e =>
                                    {
                                        e.Search();
                                        e.Custom().Text("Create New").HtmlAttributes(new { id = "btnCreateNew", @class = "btn btn-primary" });
                                    })
                                    .Pageable(p => p.Numeric(false).PreviousNext(false).Refresh(true))
                                    .Events(events => events
                                    .Sort("onSorting")
                                    .Filter("onFiltering")
                                    .Group("onGrouping")
                                    .Page("onPaging")
                                    .GroupCollapse("onGroupCollapse")
                                    .GroupExpand("onGroupExpand")
                                    .DataBound("onDataBound")
                                    .ColumnReorder("onColumnReordering")
                                    .Edit("edit")
                                     )


                                     .DataSource(dataSource => dataSource
                                        .Custom()
                                         .Type("aspnetmvc-ajax")
                                         .PageSize(500)
                                         .ServerPaging(true)
                                         .ServerFiltering(true)
                                         .ServerSorting(true)
                                         .ServerGrouping(true)
                                         .Transport(transport =>
                                         {
                                             transport.Read(read => read.Action("", ""));
                                             transport.Update(update => update.Action("", ""));
                                         }
                                         )
                                         .Schema(schema => schema
                                         .Data("data")
                                         .Total("total")
                                         .Model(m=>m.Id("id"))
                                         )
                                         )

                                 )

Here's my editor template -> LeadStatusList.cshtml:


@using Kendo.Mvc.UI
@(Html.Kendo().DropDownList()
                               .Name("Status")
                              .DataTextField("Text")
                              .DataValueField("Value")
                              .BindTo(new List<SelectListItem>() {
                                  new SelectListItem() {
                                      Text = "None",
                                      Value = "None"
                                  },
                                  new SelectListItem() {
                                      Text = "Initial Call Scheduled",
                                      Value = "Initial Call Scheduled"
                                  },
                                  new SelectListItem() {
                                      Text = "Working",
                                      Value = "Working"
                                  },
                                   new SelectListItem() {
                                      Text = "Nurturing",
                                      Value = "Nurturing"
                                  },
                                    new SelectListItem() {
                                      Text = "Unqualified",
                                      Value = "Unqualified"
                                  },
                                    new SelectListItem() {
                                      Text = "Qualified",
                                      Value = "Qualified"
                                  }
                              })
                              .Value("1")
                              .HtmlAttributes(new { style = "width: 100%" })
                        )

Zack
Top achievements
Rank 1
 asked on 10 Jul 2022
Narrow your results
Selected tags
Tags
+? more
Top users last month
Mark
Top achievements
Rank 1
Yurii
Top achievements
Rank 1
Leland
Top achievements
Rank 2
Iron
Iron
Iron
Hon
Top achievements
Rank 1
Iron
Deltaohm
Top achievements
Rank 3
Bronze
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Mark
Top achievements
Rank 1
Yurii
Top achievements
Rank 1
Leland
Top achievements
Rank 2
Iron
Iron
Iron
Hon
Top achievements
Rank 1
Iron
Deltaohm
Top achievements
Rank 3
Bronze
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?