Autocomplete editor in Grid

2 posts, 0 answers
  1. Randy
    Randy avatar
    75 posts
    Member since:
    Jul 2009

    Posted 24 Feb 2017 Link to this post

    I have a hierarchical grid, using MVC, and in the detail (child) table, I want the user to be able to create a new row and the row will contain an Autocomplete field. I have everything wired up, the grid displays correctly, with data. When the user clicks Add New Record, a new row is displayed with the Autocomplete field. However, for some reason, no data is being retrieved from the server (the controller method isn't getting called at all) when the user starts typing. Here is the code for the autocomplete editor and the detail table:

    @(Html.Kendo().AutoComplete()

              .Name("Combined")
              .ValuePrimitive(true)
              .DataTextField("Combined")
              .Filter("contains")
              .MinLength(3)
              .HtmlAttributes(new { style = "width:200px" })
              .DataSource(source =>
              {
                  source.Read(read =>
                  {
                      read.Action("GetAntiqueCategories", "Customer");
                  })
                  .ServerFiltering(false);
              })
    )

    <script id="template" type="text/kendo-tmpl">
        @(Html.Kendo().Grid<Entities.AntiqueCategory>()
                .Name("grid_#=RowId#")
                .Columns(columns =>
                {
                    columns.Bound(o => o.Combined).EditorTemplateName("Combined");
                    columns.Command(command => { command.Destroy(); }).Width(200);
                })
                .ToolBar(toolbar =>
                {
                    toolbar.Create();
                    toolbar.Save();
                })
                .DataSource(dataSource => dataSource
                    .Ajax()
                    .PageSize(10)
                    .Model(model => model.Id(p => p.RowId))
                    .Read(read => read.Action("ReadCustomerWantDetail", "Customer", new { customerId = "#=RowId#" }))
                    .Create(update => update.Action("CreateCustomerWantDetail", "Customer", new { customerId = "#=RowId#" }))
                    .Update(update => update.Action("CreateCustomerWantDetail", "Customer", new { customerId = "#=RowId#" }))
                    .Destroy(update => update.Action("DeleteCustomerWantDetail", "Customer"))
                )
                .Editable(editable => editable.Mode(GridEditMode.InCell))
                .Pageable()
                .Sortable()
                .ToClientTemplate()
        )
    </script>

  2. Tsvetina
    Admin
    Tsvetina avatar
    2481 posts

    Posted 28 Feb 2017 Link to this post

    Hello Randy,

    The AutoComplete with server filtering disabled is expected to make a call to the server only on initial load. If you enable server filtering, you will get requests every time a value is searched. 

    If there is no request on initial load, too, I cannot tell why it happens, as your snippets look ok. You can go through the article on creating editor templates to confirm that you didn't miss any configuration steps and also take a look at the sample on using an AutoComplete as a custom editor.

    If the issue persists and you cannot find its cause, please send us a runnable sample that demonstrates the problem, so we can debug it locally.

    Regards,
    Tsvetina
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top