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

Template binding for an AutoComplete field in a Pop-Up Editor

1 Answer 34 Views
AutoComplete
This is a migrated thread and some comments may be shown as answers.
Brian
Top achievements
Rank 1
Brian asked on 17 Oct 2013, 02:06 PM
I am trying to put an AutoComplete field into a GridEdit Pop-up dialog.   I am using a custom template to format the listbox.  The problem is that the listbox shows everything as 'undefined'.  If I then click on a listbox item, the correct underlying value is selected and displayed properly.

If I copy the code, take it out of the PopUp editor, and paste it directly into the parent View, then it works perfectly.

Something else I tried...
If I remove the Template altogether than the listbox displays the correct value.  I just lose my custom formatting.

I've narrowed the problem down to being the Template.  I'm certain that there is something special you have to do with your Template if you are in a Pop-up dialog.  The data is not being binded correctly.

What should I do to make the Template work right?
@(Html.Kendo().AutoComplete()
    .Name("DiaryCodeAutoComplete")
    .Filter("startswith")
    .Placeholder("Select diary code...")
    .DataTextField("Code")
    .DataSource(source =>
    {
        source.Read(read =>
        {
            read.Action("GetSelectList", "DiaryCode");
        });
    })
    .Template("<span style='font-weight: bold;'>${data.Code}</span> <span style='float:right'>${data.Name}</span>")
)


1 Answer, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 21 Oct 2013, 10:04 AM
Hi,

The most likely reason for the problem is that the expressions are evaluated in the context of the popup template. Please check if using the syntax from this documentation topic instead resolves the problem:

.Template("<span style='font-weight: bold;'>#:data.Code#</span> <span style='float:right'>#:data.Name#</span>")
Regards,
Daniel
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
AutoComplete
Asked by
Brian
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Share this question
or