Autocomplete JSON Response

4 posts, 0 answers
  1. Ben
    Ben avatar
    12 posts
    Member since:
    Mar 2012

    Posted 05 Apr 2012 Link to this post

    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"}]
  2. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 05 Apr 2012 Link to this post

    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!
  3. Kendo UI is VS 2017 Ready
  4. Ben
    Ben avatar
    12 posts
    Member since:
    Mar 2012

    Posted 05 Apr 2012 Link to this post

    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.
  5. Andrew
    Andrew avatar
    1 posts
    Member since:
    Sep 2012

    Posted 12 Sep 2012 Link to this post

    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. 
Back to Top
Kendo UI is VS 2017 Ready