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

Editor Template Dropdown List: No Initial Value

2 Answers 469 Views
Grid
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 22 May 2014, 08:28 PM
I have a Dropdown List Editor Template for a field in my Grid, and when I create a new row in the grid, the options are visible, and it appears as if the initial item is selected. However, the value of this item is not carried back to the server unless I open the drop down list and select an item.

Any Thoughts?

2 Answers, 1 is accepted

Sort by
0
Alexander Popov
Telerik team
answered on 26 May 2014, 01:51 PM
Hello David,

I would recommend adding an optionLabel to the DropDownList and/or using a default value for the Model's field bound to it. For example: 
.DataSource(dataSource => dataSource
    .Ajax()
    .Model(model =>
    {
        model.Id(p => p.ProductID);
        model.Field(p => p.CategoryID).DefaultValue(0);
    })
@model object
            
@(Html.Kendo().DropDownListFor(m => m)
    .OptionLabel("Please select")
    .BindTo((SelectList)ViewData[ViewData.TemplateInfo.GetFullHtmlFieldName("") + "_Data"])
)


Regards,
Alexander Popov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Patrick
Top achievements
Rank 1
answered on 13 Feb 2018, 01:08 PM

That is it.  Exactly what I needed.

Thanks.

Tags
Grid
Asked by
David
Top achievements
Rank 1
Answers by
Alexander Popov
Telerik team
Patrick
Top achievements
Rank 1
Share this question
or