Hi,
I'm trying to set the autofocus on my edit screens. If it's an Kendo-control that I want to have autofocus, it doesn't seem to work.
I tried setting the HtmlAttributes for de dropdownlist:
<div class="form-group">
@Html.LabelFor(model => model.IdLocation, htmlAttributes: new { @class = "control-label col-sm-2" })
<div class="col-md-10">
@(Html.Kendo().DropDownListFor(model => model.IdLocation)
.DataTextField("Value")
.DataValueField("Key")
.OptionLabel("Selecteer... ")
.HtmlAttributes(new { autofocus = "" })
.DataSource(source => source.Read(read => read.Action("GetAllItemsAsDictionary", "Location")))
)
</div>
</div>
As a result I see an input element generated with the attribute autofocus set, but also with style 'display: none'.
<div class="col-md-10">
<span aria-activedescendant="d012aecf-c5cf-41cd-b307-85b7dfad7807" aria-busy="false" aria-readonly="false" aria-disabled="false" aria-owns="IdLocation_listbox" tabindex="0" aria-expanded="false" aria-haspopup="true" role="listbox" unselectable="on" class="k-widget k-dropdown k-header" title="" style="">
<span unselectable="on" class="k-dropdown-wrap k-state-default">
<span unselectable="on" class="k-input">12a (Riek)</span>
<span unselectable="on" class="k-select">
<span unselectable="on" class="k-icon k-i-arrow-s">select</span>
</span>
</span>
<input style="display: none;" data-role="dropdownlist" autofocus="" data-val="true" data-val-number="The field Locatie must be a number." data-val-required="The Locatie field is required." id="IdLocation" name="IdLocation" value="1" type="text">
</span>
<script>
jQuery(function(){jQuery("#IdLocation").kendoDropDownList({"dataSource":{"transport":{"read":{"url":"/events/Location/GetAllItemsAsDictionary"},"prefix":""},"schema":{"errors":"Errors"}},"dataTextField":"Value","dataValueField":"Key","optionLabel":"Selecteer... "});});
</script>
</div>
So my question is how to make a Kendo dropdownlist having autofocus?
Thank you for a reply.