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

Selection returns an object as text

2 Answers 208 Views
AutoComplete
This is a migrated thread and some comments may be shown as answers.
Juuso
Top achievements
Rank 1
Juuso asked on 29 Jan 2013, 09:40 AM
I have kendo grid which has one string column that is using an autocomplete editortemplate. Now when the user first selects something from the list the text reads [object Object]. If the user does the selection again it shows up right. The editortemplate gets its values as an list of custom objects and uses one of the properties in that object. I've tried to override the ToString method of the object but alas it still returns the [object Object] on first selection. 

This same behaviour is present when using webcombo as editortemplate.

Anyone seen this behaviour before and how to fix it. I cannot reproduce it on any of the demos here so it has to do something with the setup my project is using.

The code of the column binding:
columns.Bound(o => o.Person).EditorTemplateName("Handlers");


And the template ("Handlers.cshtml"):
@(Html.Kendo().AutoComplete()
        .Filter(FilterType.StartsWith)
        .IgnoreCase(false)
        .Suggest(true) 
        .Name("Person")
        .DataTextField("Name")  
        .MinLength(1)
        .Template("#=Name#")
        .DataSource(source => { source.Read(read =>
              {
                  read.Data("GetQueryStringData").Action("GetHandlersTemplate", "AHJ").Type(HttpVerbs.Post);
              });
          })
)


Using mvc razor

2 Answers, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 31 Jan 2013, 09:57 AM
Hello Juuso,

 
I prepared a simple test project in order to replicate the issue, but to no avail. Could you please check the attached application and modify it in order to reproduce the problem ?

All the best,
Georgi Krustev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Juuso
Top achievements
Rank 1
answered on 31 Jan 2013, 01:21 PM
Sweet, thank you!

I tried to reproduce the issue with out any success. Then i checked the data which the controller was sending to the Template. Difference was that in my case i was sending Objects where as in your example was sending just a string list. After changing the controller function in my project it started to work just fine. 

Tried to reproduce the issue with your project by sending whole objects but it still worked just fine. 

All in all, my site now works as planned and this is excellent. I will probably try to reproduce the issue with your example just out of curiosity and if i can reproduce it i will let you know.


- Juuso 
Tags
AutoComplete
Asked by
Juuso
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Juuso
Top achievements
Rank 1
Share this question
or