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

Grid using XML datasource cannot show only one record

0 Answers 73 Views
Grid
This is a migrated thread and some comments may be shown as answers.
danny
Top achievements
Rank 1
danny asked on 17 Aug 2012, 02:20 AM
Here is my scripts:



<!doctype html>
<html>
    <head>
        <link href="http://cdn.kendostatic.com/2011.2.804/styles/kendo.common.min.css" rel="stylesheet"/>
        <link href="http://cdn.kendostatic.com/2011.2.804/styles/kendo.kendo.min.css" rel="stylesheet"/>
        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
        <script src="http://cdn.kendostatic.com/2011.2.804/js/kendo.all.min.js"></script>
    </head>
    <body>
        <div id="grid"></div>
        <script type="text/javascript">
                $(document).ready(function() {
                    $("#grid").kendoGrid({
                        dataSource:  new kendo.data.DataSource({
                            transport: {
                                // specify the XML file to read. The same as read: { url: "books.xml" }
                                read: "books.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"
                                    }
                                }
                            }
                        }),
                        scrollable: false,
                        sortable: true
                    });
                });
            </script>
    </body>
</html>




the books.xml contains valid xml record. The web page correctly show the result if the books.xml contain more than one record.
However, if there is only one record in the books.xml, the web page show nothing.

Is it a bug? Is there any way to avoid/fix it?

Thank you.

No answers yet. Maybe you can help?

Tags
Grid
Asked by
danny
Top achievements
Rank 1
Share this question
or