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

Grid inline edit with Autocomplete Editor as EditorTemplate

1 Answer 441 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Pradeep
Top achievements
Rank 1
Pradeep asked on 07 Sep 2018, 09:07 AM

Hi, On clicking update after selecting item from autocomplete editor , the newly selected value is not updated back in the grid .Instead the previous value is shown again. (the selected value appears in cell before clicking update)

Did I miss any configuration? No errors in console.

Thanks!

@(Html.Kendo().Grid(Model.Customers)
                    .Name("grid")
                    .Columns(columns =>
                    {
                        columns.Bound(p => p.Id);
                        columns.Bound(p => p.FirstName).EditorTemplateName("AutoCompleteEditor");
                        columns.Command(command => { command.Edit(); command.Destroy(); }).Width(250);
                    })
                    .HtmlAttributes(new { style = "height: 480px;" })
                    .ToolBar(toolbar => toolbar.Create())
                    .Editable(editable => editable.Mode(GridEditMode.InLine))
            .Scrollable()
            .Sortable()
            .Filterable()
            .Pageable(pageable => pageable
            .Refresh(true)
            .PageSizes(true)
            .ButtonCount(5)           
            )
            .DataSource(dataSource => dataSource
            .Ajax()
            .ServerOperation(false)
            .Read(read => read.Action("Index", "Grid"))
            )
            .Events(events => events.Change("onChange"))
    )

AutoCompleteEditor.cshtml
@(Html.Kendo().AutoCompleteFor(m => m.Customer)
                .Filter("startswith")
                .DataTextField("firstName")
                .ValuePrimitive(true)
                .Placeholder("Select customer...")
                .DataSource(source =>
                {
                    source.Read(read =>
                    {
                        read.Action("GetCustomer", "Grid");
                    })
                    .ServerFiltering(false);
                })
)

1 Answer, 1 is accepted

Sort by
0
Tsvetina
Telerik team
answered on 11 Sep 2018, 02:30 PM
Hi Pradeep,

It looks like the editor is not set to work with the actual type of the FirstName column. I assume the column is of type string, so the AutoComplete should not be set to bind to a Customer property. Try the following:

AutoCompleteEditor.cshtml
@model string;
 
@(Html.Kendo().AutoCompleteFor(m => m)
    .Filter("startswith")
    .DataTextField("firstName")
    .ValuePrimitive(true)
    .Placeholder("Select customer...")
    .DataSource(source =>
    {
        source.Read(read =>
        {
            read.Action("GetCustomer", "Grid");
        })
        .ServerFiltering(false);
    })
)

or alternatively:
@model string;
  
@(Html.Kendo().AutoComplete()
    .Name("FirstName")
    .Filter("startswith")
    .DataTextField("firstName")
    .ValuePrimitive(true)
    .Placeholder("Select customer...")
    .DataSource(source =>
    {
        source.Read(read =>
        {
            read.Action("GetCustomer", "Grid");
        })
        .ServerFiltering(false);
    })
)


Regards,
Tsvetina
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
Grid
Asked by
Pradeep
Top achievements
Rank 1
Answers by
Tsvetina
Telerik team
Share this question
or