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

autocomplete

2 Answers 332 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Louis
Top achievements
Rank 1
Iron
Iron
Iron
Louis asked on 18 Aug 2019, 04:02 PM

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">

 

 

 

2 Answers, 1 is accepted

Sort by
0
Georgi
Telerik team
answered on 20 Aug 2019, 11:24 AM
Hi Louis,

Indeed the issue is due to the wrong name of the input.

Could you please test the same by configuring the editor via the AutoCompleteFor helper and removing the name?

e.g.

@model string
  
@(Html.Kendo().AutoCompleteFor(x=> x)
          .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);
          })
)


Regards,
Georgi
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Louis
Top achievements
Rank 1
Iron
Iron
Iron
answered on 20 Aug 2019, 02:17 PM

Hello Georgi ,

You absolutely right.  Now it's work #1. 

 

THANK A LOT GEORGI FOR YOUR TIME AND TALENT.

Tags
Grid
Asked by
Louis
Top achievements
Rank 1
Iron
Iron
Iron
Answers by
Georgi
Telerik team
Louis
Top achievements
Rank 1
Iron
Iron
Iron
Share this question
or