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

Dropdown showing as textbox

1 Answer 1396 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
Marta
Top achievements
Rank 1
Marta asked on 16 Apr 2020, 08:57 AM

Hi,

I am facing the following issue: my dropdown, that is inside a Kendo UI grid, is showing as textbox.

Here is the code of the grid:

@model Portal.Web.Areas.Orders.Models.IngressoMerceViewModel<br><br>@(Html.Kendo().Grid<Portal.Web.Areas.Orders.Models.IngressoMerceGridViewModel>()<br>    .Name("grid")<br>    .Events(e => e.DataBound(@<text>function() {for (var i = 0; i @Html.Raw("<") this.columns.length; i++) {this.autoFitColumn(i);}}</text>))<br>.Columns(columns =><br>{<br>columns.Template("<input type='checkbox' />");<br>columns.Bound(p => p.Posizione).Title("Posizione").Width(200);<br>columns.Bound(p => p.Materiale).Title("Materiale").Width(200);<br>columns.Bound(p => p.Description).Title("Testo breve").Width(200);<br>columns.Bound(p => p.WarehouseLogicStore)<br>    .Editable("false").Width(200)<br>.ClientTemplate(Html.Kendo().DropDownList().Events(e => e.Change("change"))<br>.Name("WHLogicValue").DataTextField("Code").DataValueField("Code").DataSource(source =><br>{<br>source.Read(read =><br>{<br>read.Action("WarehouseLogicTypes_Read", "IngressoMerce");<br>});<br>}).Deferred(!Model.IsAjax).ToClientTemplate().ToString()<br><br>);<br>columns.Bound(p => p.Quantity).Title("Qta Ordine").Width(200);<br>columns.Bound(p => p.UnitOfMeasure).Title("UM").Width(200);<br>columns.Bound(p => p.ReceivedQty).Title("Qta giĆ  ricevute").Width(200);<br>columns.Template("<input type='text' value=#= InProgressQtyCheck# onclick=\"myFunction(p)\"/>").Title("Qta ricevute");<br>columns.Template("<input type='checkbox' />").Title("Completa Pos.Ordine");<br>columns.Bound(p => p.InProgressQtyCheck).Title("Qta da ricevere").Width(200);<br>columns.Bound(p => p.ExpectedDeliveryDate).Format("{0:dd/MM/yyyy}").Title("Data consegna prevista").Width(200);<br>columns.Bound(p => p.QualityCheckNeeded).Title("Check qualitativo richiesto").Width(220);<br>})<br>.Pageable()<br>.Sortable()<br>.Scrollable()<br>.HtmlAttributes(new { style = "height:430px;" })<br>.DataSource(dataSource => dataSource<br>.Ajax()<br>//.Read(read => read.Url("/orders/details").Type(HttpVerbs.Get))<br>.Read(read => read.Action("OrderDetails_Read", "IngressoMerce", Model))<br>)<br>.Deferred(!Model.IsAjax)<br><br><br><br>)<br><br><br><br>    <script><br>        myFunction(p)<br>        {<br><br>        }<br>    </script>

 

Here is the call of the action method, that does not fire in the controller:

[AllowAnonymous]
        public async Task<JsonResult> WarehouseLogicTypes_Read()
        {
            try
            {
                var types = await gateway.GetWarehouseLogicTypes();

                return Json(types);
            }
            catch (Exception ex)
            {
                //logger.LogError(ex.Message);
                throw ex;
            }
        }

 

1 Answer, 1 is accepted

Sort by
0
Aleksandar
Telerik team
answered on 17 Apr 2020, 12:58 PM

Hello Marta,

Are there any errors logged in the developers' console, that would help diagnose the issue? I would also suggest checking the article below on the correct way to initialize Kendo widgets in ClientTemplates when using server-side helpers:

https://docs.telerik.com/aspnet-mvc/html-helpers/data-management/grid/faq?#how-can-i-use-kendo-ui-widgets-inside-grid-client-column-templates

From the provided code snippet I noticed that the name of all the DropDownLists that would be initiated would be the same. This would cause issues and needs to be updated, for example, by adding the ID of the dataItem to the name:

.ClientTemplate(
    Html.Kendo().DropDownList()
        .Name("WHLogicValue_#=ItemID#") //assuming ItemID is the property name for the ID
...
)

Give these suggestions a try and let me know if the issue is resolved.

Regards,
Aleksandar
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
Tags
DropDownList
Asked by
Marta
Top achievements
Rank 1
Answers by
Aleksandar
Telerik team
Share this question
or