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

DropDownList not populating with Data from Datasource

5 Answers 259 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
Troy Clemons
Top achievements
Rank 1
Troy Clemons asked on 17 Apr 2014, 09:22 PM

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










5 Answers, 1 is accepted

Sort by
0
Accepted
Kiril Nikolov
Telerik team
answered on 18 Apr 2014, 11:21 AM
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!
 
0
Troy Clemons
Top achievements
Rank 1
answered on 18 Apr 2014, 11:48 AM
Kiril,
Thank you, that fixed the problem. It is always the little things that you miss.

once again thank you.

Troy
0
Kiril Nikolov
Telerik team
answered on 18 Apr 2014, 11:56 AM
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!
 
0
Troy Clemons
Top achievements
Rank 1
answered on 18 Apr 2014, 12:15 PM
Well since you offered. :)

how would I go about getting the selected value from the above code sequence.
0
Kiril Nikolov
Telerik team
answered on 21 Apr 2014, 10:58 AM
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!
 
Tags
DropDownList
Asked by
Troy Clemons
Top achievements
Rank 1
Answers by
Kiril Nikolov
Telerik team
Troy Clemons
Top achievements
Rank 1
Share this question
or