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

AutoComplete control not rendering in Grid popup editor

1 Answer 97 Views
AutoComplete
This is a migrated thread and some comments may be shown as answers.
Stuart
Top achievements
Rank 1
Stuart asked on 31 Aug 2018, 12:49 PM

I'm trying to use an AutoComplete component in the popup editor window for a grid.

Here's the grid code:

@(Html.Kendo().Grid<Contract>(Model.Contracts)
    .Name("contractGrid")
    .Columns(columns =>
    {
        columns.Bound(model => model.Name);
        columns.Bound(model => model.StartDate).EditorTemplateName("_DatePicker").Format("{0:dd MMM yyyy}");
        columns.ForeignKey(model => model.WithdrawalReasonId, Model.AllWithdrawalReasons, "Id", "Value");
        columns.Bound(model => model.Country).EditorTemplateName("_AutoComplete");
        columns.Command(command =>
        {
            command.Edit();
        }).Width(172);
    })
    .Events(e => e.DataBound("contractGridEdit"))
    .ToolBar(toolbar => toolbar.Create())
    .Editable(editable => editable.Mode(GridEditMode.PopUp))
    .DataSource(dataSource => dataSource
        .Ajax()
        .PageSize(20)
        .ServerOperation(false)
        .Model(model =>
        {
            model.Id(p => p.Id);
            model.Field(p => p.ClinicianId).Editable(false).DefaultValue(Model.Id);
        })
        .Create(update => update.Action("ContractCreateAndEdit", "Clinician").AddRequestVerificationTokenData())
        .Update(update => update.Action("ContractCreateAndEdit", "Clinician").AddRequestVerificationTokenData())
    )
)

 

Here's the AutoComplete editor template (_AutoComplete.cshtml):

@using Kendo.Mvc.UI
@model object
 
@(Html.Kendo().AutoComplete()
    .Name("Country")
    .Filter("startswith")
    .MinLength(3)
    .BindTo(new string[] {
        "Albania",
        "Andorra",
        "Armenia",
        "Austria",
        "Azerbaijan",
        "Belarus",
        "Belgium" }
    )
)

 

I've tried various options for the name of theAutoComplete control but cannot get it to render in the grid popup. What am I missing?

Thanks,
Stuart.

1 Answer, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 03 Sep 2018, 02:13 PM
Hello Stuart,

In the described scenario you can use the AutoCompleteFor instead:
https://docs.telerik.com/aspnet-mvc/helpers/autocomplete/overview#model-binding

Give it a try and let me know if this resolves the issue.

Regards,
Eyup
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.
Tags
AutoComplete
Asked by
Stuart
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Share this question
or