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

Getting undefined values when using XML datasource

1 Answer 130 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
Patrick
Top achievements
Rank 1
Patrick asked on 28 Oct 2011, 11:48 AM
Hi, I'm trying to populate a dropdown list using XML that was retrieved from a web service which I pass two arguments to. The list seems to be displaying the right number of items, however they all appear as "undefined". Here is my code:

$("#dropdownbox").kendoDropDownList({
    dataSource: new kendo.data.DataSource({
        dataTextField: "name",
        dataValueField: "id",                       
        transport: {
            read: {
                url: "WebService.asmx/GetDates",
                data: {
                    startDate: "2010/10/20",
                    endDate: "2012/10/20"
                }   
            }
        },
        schema: {
            type: "xml",
            data: "NewDataSet/dates",
            model: {
                fields: {
                    building_name: "name/text()",
                    building_id: "id/text()"
                }
            }
        }
 
    })                       
});

Here is the XML that is returned by the web service:

<NewDataSet>
    <dates>
        <id>4</id>
        <name>TestItem1</name>
    </dates>
    <dates>
        <id>5</id>
        <name>TestItem2</name>
    </dates>
</NewDataSet>

Any help would be appreciated!

1 Answer, 1 is accepted

Sort by
0
Patrick
Top achievements
Rank 1
answered on 28 Oct 2011, 12:52 PM
Nevermind I fixed it. I Had the dataTextField and dataValueField nested under datasource, dumb mistake. Here is the working code:

$("#dropdownbox").kendoDropDownList({
    dataTextField: "name",
    dataValueField: "id",            
    dataSource: new kendo.data.DataSource({       
        transport: {
            read: {
                url: "WebService.asmx/GetDates",
                data: {
                    startDate: "2010/10/20",
                    endDate: "2012/10/20"
                
            }
        },
        schema: {
            type: "xml",
            data: "NewDataSet/dates",
            model: {
                fields: {
                    building_name: "name/text()",
                    building_id: "id/text()"
                }
            }
        }
   
    })                     
});
Tags
DropDownList
Asked by
Patrick
Top achievements
Rank 1
Answers by
Patrick
Top achievements
Rank 1
Share this question
or