DropDownList not populating with Data from Datasource

6 posts, 1 answers
  1. Troy Clemons
    Troy Clemons avatar
    69 posts
    Member since:
    Apr 2010

    Posted 17 Apr 2014 Link to this post


    Called CSS and JS files from telerik
            <link href="http://cdn.kendostatic.com/2014.1.416/styles/kendo.default.min.css" rel="stylesheet" />
            <link href="http://cdn.kendostatic.com/2014.1.416/styles/kendo.mobile.all.min.css" rel="stylesheet" />
            <script src="http://cdn.kendostatic.com/2014.1.416/js/jquery.min.js"></script>
            <script src="http://cdn.kendostatic.com/2014.1.416/js/kendo.all.min.js"></script>
    HTML

    <body>
        <div style="margin-top: 25px; margin-left: 180px">
                  <input id="bookyear" style="width: 150px;" />
         </div>
        <script>
            $(document).ready(function () {
                $("#bookyear").kendoDropDownList({
                    dataTextField: "Book",
                    dataValueField: "RegionSize",
                    dataSource: {
                        transport: {
                            read: {
                                type: "POST",
                                contentType: "application/json; charset=utf-8",
                                //data: "{}",
                                dataType: "json",
                                url: "Default2.aspx/GetBooks",
                            }
                        }
                    }
                });
            });
        </script>
        <script>
            var app = new kendo.mobile.Application(document.body, {
                transition: 'slide'
            });
     
            //function showLoading() {
            //    app.showLoading();
            //    setTimeout(function () {
            //        app.changeLoadingMessage("Getting Data... Please wait...");
            //    }, 1000);
            //}
            </script>
    </body>
    </html>

    The Returned JSON from fiddler
    {"d":[{"__type":"SpecMobi.Books","Book":"ABTX","RegionSize":"Texas_Tall3"},{"__type":"SpecMobi.Books","Book":"ASPN","RegionSize":"West_Short3"},{"__type":"SpecMobi.Books","Book":"BATE","RegionSize":"East_Short2"},{"__type":"SpecMobi.Books","Book":"BCTX","RegionSize":"Texas_Tall3"},{"__type":"SpecMobi.Books","Book":"BRAN","RegionSize":"East_Tall2"},{"__type":"SpecMobi.Books","Book":"BRBN","RegionSize":"East_Short2"},{"__type":"SpecMobi.Books","Book":"BVAR","RegionSize":"East_Short2"},{"__type":"SpecMobi.Books","Book":"CARL","RegionSize":"Texas_Tall2"},{"__type":"SpecMobi.Books","Book":"CEMS","RegionSize":"East_Tall2"},{"__type":"SpecMobi.Books","Book":"CHER","RegionSize":"East_Tall2"},{"__type":"SpecMobi.Books","Book":"CMOK","RegionSize":"East_Short2"},{"__type":"SpecMobi.Books","Book":"CRAG","RegionSize":"West_Short2"},{"__type":"SpecMobi.Books","Book":"CRAW","RegionSize":"East_Tall2"},{"__type":"SpecMobi.Books","Book":"CRTH","RegionSize":"East_Short2"},{"__type":"SpecMobi.Books","Book":"DLTA","RegionSize":"West_Tall2"},{"__type":"SpecMobi.Books","Book":"ENMR","RegionSize":"Texas_Tall2"},{"__type":"SpecMobi.Books","Book":"ESPN","RegionSize":"West_Short2"},{"__type":"SpecMobi.Books","Book":"ESTE","RegionSize":"East_Tall2"},{"__type":"SpecMobi.Books","Book":"EURE","RegionSize":"East_Short2"},{"__type":"SpecMobi.Books","Book":"FOUR","RegionSize":"East_Short2"},{"__type":"SpecMobi.Books","Book":"FTSM","RegionSize":"East_Tall3"},{"__type":"SpecMobi.Books","Book":"GRCT","RegionSize":"West_Short2"},{"__type":"SpecMobi.Books","Book":"GROV","RegionSize":"East_Short2"},{"__type":"SpecMobi.Books","Book":"GRTD","RegionSize":"East_Short2"},{"__type":"SpecMobi.Books","Book":"HARR","RegionSize":"East_Tall2"},{"__type":"SpecMobi.Books","Book":"HOBB","RegionSize":"Texas_Tall2"},{"__type":"SpecMobi.Books","Book":"JBAR","RegionSize":"East_Short3"},{"__type":"SpecMobi.Books","Book":"JPLN","RegionSize":"East_Tall3"},{"__type":"SpecMobi.Books","Book":"KFTX","RegionSize":"Texas_Tall3"},{"__type":"SpecMobi.Books","Book":"KVTX","RegionSize":"Texas_Short2"},{"__type":"SpecMobi.Books","Book":"LCVI","RegionSize":"West_Tall2"},{"__type":"SpecMobi.Books","Book":"LHRP","RegionSize":"East_Short2"},{"__type":"SpecMobi.Books","Book":"LOAL","RegionSize":"West_Short2"},{"__type":"SpecMobi.Books","Book":"LSVG","RegionSize":"West_Short2"},{"__type":"SpecMobi.Books","Book":"LUTX","RegionSize":"Texas_Short4"},{"__type":"SpecMobi.Books","Book":"MAYE","RegionSize":"East_Short2"},{"__type":"SpecMobi.Books","Book":"MCID","RegionSize":"West_Short2"},{"__type":"SpecMobi.Books","Book":"MGCT","RegionSize":"East_Short2"},{"__type":"SpecMobi.Books","Book":"MLTX","RegionSize":"Texas_Tall3"},{"__type":"SpecMobi.Books","Book":"MONE","RegionSize":"East_Short2"},{"__type":"SpecMobi.Books","Book":"MOSC","RegionSize":"West_Tall2"},{"__type":"SpecMobi.Books","Book":"NEOS","RegionSize":"East_Short2"},{"__type":"SpecMobi.Books","Book":"NVDA","RegionSize":"East_Short2"},{"__type":"SpecMobi.Books","Book":"NWAR","RegionSize":"East_Tall3"},{"__type":"SpecMobi.Books","Book":"ODTX","RegionSize":"Texas_Tall3"},{"__type":"SpecMobi.Books","Book":"OXFD","RegionSize":"East_Short2"},{"__type":"SpecMobi.Books","Book":"OZNX","RegionSize":"East_Short2"},{"__type":"SpecMobi.Books","Book":"PENV","RegionSize":"Texas_Tall2"},{"__type":"SpecMobi.Books","Book":"PGAR","RegionSize":"East_Short2"},{"__type":"SpecMobi.Books","Book":"PITT","RegionSize":"East_Tall2"},{"__type":"SpecMobi.Books","Book":"PRSN","RegionSize":"East_Short2"},{"__type":"SpecMobi.Books","Book":"ROSW","RegionSize":"Texas_Tall2"},{"__type":"SpecMobi.Books","Book":"SARK","RegionSize":"East_Short2"},{"__type":"SpecMobi.Books","Book":"SNAN","RegionSize":"Texas_Tall3"},{"__type":"SpecMobi.Books","Book":"SOTX","RegionSize":"Texas_Short2"},{"__type":"SpecMobi.Books","Book":"SPFD","RegionSize":"East_Tall3"},{"__type":"SpecMobi.Books","Book":"SSAR","RegionSize":"East_Short2"},{"__type":"SpecMobi.Books","Book":"STBT","RegionSize":"West_Tall2"},{"__type":"SpecMobi.Books","Book":"STFE","RegionSize":"West_Tall2"},{"__type":"SpecMobi.Books","Book":"SUMM","RegionSize":"West_Short3"},{"__type":"SpecMobi.Books","Book":"SUNV","RegionSize":"West_Short3"},{"__type":"SpecMobi.Books","Book":"SWID","RegionSize":"West_Tall2"},{"__type":"SpecMobi.Books","Book":"TAOS","RegionSize":"West_Tall2"},{"__type":"SpecMobi.Books","Book":"TBTX","RegionSize":"Texas_Tall3"},{"__type":"SpecMobi.Books","Book":"TELL","RegionSize":"West_Short2"},{"__type":"SpecMobi.Books","Book":"VAIL","RegionSize":"West_Short3"},{"__type":"SpecMobi.Books","Book":"WNMR","RegionSize":"Texas_Short2"}]}

    The DropDownList is blank, no data. nothing.


    what am I missing here










  2. Answer
    Kiril Nikolov
    Admin
    Kiril Nikolov avatar
    2565 posts

    Posted 18 Apr 2014 Link to this post

    Hello Troy,

    Your data is returned as an object, so you need to tell the dataSource where to find the array with the data. This is done using the schema.data configuration of the dataSource. I have also created the following working example:

    http://jsbin.com/dokew/1/edit

    Regards,
    Kiril Nikolov
    Telerik
     
    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. Troy Clemons
    Troy Clemons avatar
    69 posts
    Member since:
    Apr 2010

    Posted 18 Apr 2014 Link to this post

    Kiril,
    Thank you, that fixed the problem. It is always the little things that you miss.

    once again thank you.

    Troy
  5. Kiril Nikolov
    Admin
    Kiril Nikolov avatar
    2565 posts

    Posted 18 Apr 2014 Link to this post

    Hi Troy,

    You are very welcome.

    In case you have any further questions, please do not hesitate.

    Regards,
    Kiril Nikolov
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  6. Troy Clemons
    Troy Clemons avatar
    69 posts
    Member since:
    Apr 2010

    Posted 18 Apr 2014 Link to this post

    Well since you offered. :)

    how would I go about getting the selected value from the above code sequence.
  7. Kiril Nikolov
    Admin
    Kiril Nikolov avatar
    2565 posts

    Posted 21 Apr 2014 Link to this post

    Hello Troy,

    You can use the value method for this:

    http://docs.telerik.com/kendo-ui/api/web/dropdownlist#methods-value

    Regards,
    Kiril Nikolov
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
Back to Top
Kendo UI is VS 2017 Ready