autocomplete

3 posts, 0 answers
  1. Louis
    Louis avatar
    85 posts
    Member since:
    Jun 2011

    Posted 18 Aug 2019 Link to this post

    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. Georgi
    Admin
    Georgi avatar
    684 posts

    Posted 20 Aug 2019 Link to this post

    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.
  3. Louis
    Louis avatar
    85 posts
    Member since:
    Jun 2011

    Posted 20 Aug 2019 in reply to Georgi Link to this post

    Hello Georgi ,

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

     

    THANK A LOT GEORGI FOR YOUR TIME AND TALENT.

Back to Top