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

Autocomplete JSON Response

3 Answers 659 Views
AutoComplete
This is a migrated thread and some comments may be shown as answers.
Ben
Top achievements
Rank 1
Ben asked on 05 Apr 2012, 05:54 AM
Hey there,

I was wondering if you can explain to me why I get the following error:

"d.name is undefined"

JS:
$(function () {
    $("#id_purchase_place").kendoAutoComplete({
        minLength:3,
        dataTextField:'name',
        dataSource:{
            serverPaging:true,
            pageSize:20,
            contentType:'application/json; charset=utf-8',
            type:'GET',
            dataType:'json',
            transport:{
                read:'/purchases/ajaxpurchase_place/'
            }
        }
    })
});

JSON RESPONSE
[{"name": "Woolies"}, {"name": "Bunnings"}]

3 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 05 Apr 2012, 07:39 AM
Hello,

 I couldn't reproduce this problem. Here is a jsfiddle showing how things look at my side: http://jsfiddle.net/korchev/w9bxj/1/ 

Kind regards,
Atanas Korchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Ben
Top achievements
Rank 1
answered on 05 Apr 2012, 08:38 AM
Thanks for your help I had a slightly different syntax to yours in the javascript, cheers!

Mine now reads:

    $("#id_purchase_place").kendoAutoComplete({
        minLength:3,
        dataTextField:'name',
        dataSource:{
            transport:{
                read:{
                    url:'/purchases/ajaxpurchase_place/',
                    serverPaging:true,
                    pageSize:20,
                    contentType:'application/json; charset=utf-8',
                    type:'GET',
                    dataType:'json'
                }
            }
        }
    })

Which is different then what it says you need to do on the "Bind to remote data" overview page btw.
0
Andrew
Top achievements
Rank 1
answered on 13 Sep 2012, 12:45 AM
Thanks Ben.  This was very frustrating until I found your thread.  The provided ajax auto-complete example (kendoui.web.2012.2.710.open-source/examples/web/autocomplete/remotedatasource.html) did not specify the arguments needed to migrate from the "dataSource" object to the "read" object. 
Tags
AutoComplete
Asked by
Ben
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Ben
Top achievements
Rank 1
Andrew
Top achievements
Rank 1
Share this question
or