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

Autocomplete editor in Grid

1 Answer 417 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Randy
Top achievements
Rank 1
Randy asked on 24 Feb 2017, 03:22 PM

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>

1 Answer, 1 is accepted

Sort by
0
Tsvetina
Telerik team
answered on 28 Feb 2017, 10:32 AM
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.
Tags
Grid
Asked by
Randy
Top achievements
Rank 1
Answers by
Tsvetina
Telerik team
Share this question
or