why doesn't $('#MyDropDownControlID').data("kendoDropDownList").dataSource.get(1) work?

2 posts, 0 answers
  1. Stanley
    Stanley avatar
    11 posts
    Member since:
    Aug 2012

    Posted 01 Oct 2012 Link to this post

    All it ever returns for me is an 'undefined' on a kendo.dropdownlist which clearly has multiple items in its content.  
  2. Nohinn
    Nohinn avatar
    167 posts
    Member since:
    Feb 2011

    Posted 02 Oct 2012 Link to this post

    Have you set the id of the model?
    To get the correct result when you use the dataSource.get function you must define which field should be used as the identifier of the items so then it searches for an item which id field has the value you pass to the get function.
    To do so:
    $('#MyDropDownControlID').kendoDropDownList({
        dataSource: {
            transport: {
                read: "url"
            },
            schema: {
                model: {
                    id: 'IdField'
                }
            }
        },
        dataValueField: 'ValueField',
        dataTextField: 'TextField'
    });

    After that if you use dataSource.get(whatever) you will get the item data.
Back to Top