Grid In-Line edit with AutoComplete results in [object Object]

2 posts, 0 answers
  1. Jonathan
    Jonathan avatar
    1 posts
    Member since:
    Jun 2014

    Posted 22 Apr 2015 Link to this post

    I've got a Grid with a cell that has an editor template that contains an auto complete object.

    When the edit for this cell is complete, the grid displays the data as "[object Object]".

    If the user goes back and uses the auto complete to select a field, the correct string is passed back to the Grid from the Editor template, however the auto complete functionality becomes buggy. (no javascript errors are thrown)

     Grid Code:

    c.Bound(a => a.InputDebtorName).Title("Debtor").EditorTemplateName("InputDebtorName") //Shows valued of [object Object] the first time it is edited, shows correct value if user goes back to edit cell again
        .DataSource(ds => ds.Ajax()
        .Model(m =>
            m.Id(p =>p.InputId);
        .Create(create => create.Action("PendingBatchListingInputCreate", "PendingBatchListing"))
        .Update(update => update.Action("PendingBatchListingInputUpdate", "PendingBatchListing"))
        .Read(r => r.Action("PendingBatchListingInputRead", "PendingBatchListing")

    Editor Template Code:

    @model object
        function onAdditionalDataDebtorSearch() {
            return {
                debtorName: $("#InputDebtorName").val(),
                clientId: null
        .Placeholder("Select Debtor")
        .DataSource(source =>
            source.Read(read =>
                read.Action("ReadDebtorSearch", "PendingBatchListing")
            "<span>" +
                "#=data.Name#  | #=data.City#, #=data.State#" +

  2. Nikolay Rusev
    Nikolay Rusev avatar
    2289 posts

    Posted 24 Apr 2015 Link to this post

    Hello Jonathan,


    This behavior is due to the fact that you are binding the AutoComplete with objects as data. Thus when you choose a value the field in the Grid will be set as that object instead as the string.


    In order to avoid this you should set ValuePrimitive(true) of the AutoComplete. Thus the widget will use the DataTextField, i.e the Name field, from the selected item to set as value of the InputDebtorName.


    Nikolay Rusev

    See What's Next in App Development. Register for TelerikNEXT.

Back to Top