Hello,
I'm trying to use autocomplete in a Batch Editing Grid. After selecting a value from the autocomplete list when I leave the field the old value stay in the text zone. See attachment to understand better.
This is my view.
@(Html.Kendo().Grid<
SafetyStudioWeb.Areas.Maintenance.ViewModels.Equipe.EquipemModell
>()
.Name("Equipement")
.Columns(columns =>
{
columns.Bound(p => p.DateIntervention).Format("{0:yyyy-MM-dd}").Width(70).HtmlAttributes(new { style = "text-align:center" });
columns.Bound(p => p.NombreHeuresUtilisationIntervention).Width(50).HtmlAttributes(new { style = "text-align:center" });
columns.Bound(p => p.ResponsableEntretienIntervention).Width(80).EditorTemplateName("AutoCompleteResponsableEntretienIntervention");
columns.Command(command => { command.Destroy(); }).HtmlAttributes(new { style = "text-align:center" }).Width(95);
})
.ToolBar(toolBar =>
{
toolBar.Create();
toolBar.Save();
})
.Editable(editable => editable.Mode(GridEditMode.InCell))
.HtmlAttributes(new { style = "font-size:11px;height: 300px;" })
.Scrollable()
.Selectable(s => s.Enabled(false))
.Pageable(pageable => pageable
.Refresh(true)
.ButtonCount(5))
.DataSource(dataSource => dataSource
.Ajax()
.Batch(true)
.ServerOperation(false)
.PageSize(100)
.Model(model =>
{
model.Field(field => field.DateIntervention).DefaultValue(System.DateTime.Now);
})
.Sort(a => a.Add("DateIntervention").Descending()).Sort(a => a.Add("NombreHeuresUtilisationIntervention").Descending())
.Read(read => read.Action("SommaireEquipementIntervention", "Equipements", new { Id = Model.EquipementId }))
.Create(create => create.Action("CreateEquipementIntervention", "Equipements", new { Id = Model.EquipementId }))
.Update(update => update.Action("UpdateEquipementIntervention", "Equipements"))
.Destroy(destroy => destroy.Action("DestroyEquipementIntervention", "Equipements"))
)
)
And the EditorTemplate :
@model string
@(Html.Kendo().AutoComplete()
.Name("ResponsableEntretienIntervention")
.Filter(FilterType.StartsWith)
.MinLength(0)
.HtmlAttributes(new { style = "width:100%" })
.DataSource(source =>
{
source.Read(read =>
{
read.Action("ObtenirResponsable", "Equipements", new { area = "Maintenance" })
.Data("onAdditionalDataResponsableEntretienIntervention");
})
.ServerFiltering(true);
})
)
I try with @(Html.Kendo().AutoCompleteFor(m => m)… but it's worst. Everything diseapear.
I think I see with Developers Tools is the ID and Name of the control change for this (the name get _ and repeat) :
<input id="ResponsableEntretienIntervention_ResponsableEntretienIntervention" name="ResponsableEntretienIntervention.ResponsableEntretienIntervention" style="" type="text" value="" data-role="autocomplete" class="k-input" autocomplete="off" role="textbox" aria-haspopup="true" aria-disabled="false" aria-readonly="false" aria-owns="ResponsableEntretienIntervention_ResponsableEntretienIntervention_listbox" aria-autocomplete="list" data-bind="value:ResponsableEntretienIntervention.ResponsableEntretienIntervention">