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

Pulling my hair out trying to get a DropDownList to load an XML file

1 Answer 141 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Benjamin
Top achievements
Rank 1
Benjamin asked on 22 Oct 2011, 08:30 PM
I don't think the examples are very clear. I have an XML file that's on my server (remote). I want a simple DropDownList that loads it, with no templates (for now). I can't get it to work, and no errors are being thrown. Please I would really appreciate a simple example that does this.

1 Answer, 1 is accepted

Sort by
0
Benjamin
Top achievements
Rank 1
answered on 22 Oct 2011, 09:14 PM
Ok, I have it working now.

                <select id="accounts" style="width:200px;">       
            </select>


     
        <script>


            $("#accounts").kendoDropDownList({
                index: 0,
                dataTextField: "title",
                dataValueField: "title",
                filter: "contains",
                dataSource: {
                    type: "xml",
                    severFiltering: false,
                    serverPaging: false,
                    pageSize: 20,
                    transport: {
                        read: "GetData.xml"
                    },
                    schema: {
                            // specify the the schema is XML
                            type: "xml",
                            // the XML element which represents a single data record
                            data: "/books/book",
                            // define the model - the object which will represent a single data record
                            model: {
                                // configure the fields of the object
                                fields: {
                                    // the "title" field is mapped to the text of the "title" XML element
                                    title: "title/text()",
                                    // the "author" field is mapped to the text of the "author" XML element
                                    author: "author/text()",
                                    // the "url" field is mapped to the text of the "url" XML element
                                    url: "url/text()",
                                    // the "cover" field is mapped to the "id" attribute of the "book" XML element
                                    cover: "@@cover"
                                }
                            }
                        }
                }
            });
        </script>
Tags
Data Source
Asked by
Benjamin
Top achievements
Rank 1
Answers by
Benjamin
Top achievements
Rank 1
Share this question
or