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

remote xml datasource (prestashop webservice)

1 Answer 70 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Jose
Top achievements
Rank 1
Jose asked on 13 Jul 2012, 02:44 PM
Hi, i'm new to this forums, and i'm testing your fantastic jquery library.
i've looking for a solution in the forums, but no one found.
I'm using prestashop webservices and i have this code:(modified from one sample)

<!DOCTYPE html>
<html>
<head>
    <title>Binding to remote data</title>
    <link href="../../content/shared/styles/examples-offline.css" rel="stylesheet">
    <link href="../../../styles/kendo.common.min.css" rel="stylesheet">
    <link href="../../../styles/kendo.default.min.css" rel="stylesheet">
    <script src="../../../js/jquery.min.js"></script>
    <script src="../../../js/kendo.web.min.js"></script>
    <script src="../../content/shared/js/console.js"></script>
</head>
<body>
    <a class="offline-button" href="../index.html">Back</a>
        <div id="example" class="k-content">
            <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: "http://mykey@localhost/orion/api/customers/1"
                            },
                            schema: {
                                // specify the the schema is XML
                                type: "xml",
                                // the XML element which represents a single data record
                                data: "/prestashop/customer",
                                // 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
                                        elid: "id/text()",
                                        // the "author" field is mapped to the text of the "author" XML element
                                        nombre: "firstname/text()",
                                        // the "url" field is mapped to the text of the "url" XML element
                                        apellidos: "lastname/text()",
                                        
                                    }
                                }
                            }
                        }),
                        scrollable: false,
                        sortable: true
                    });
                });
            </script>
        </div>
</body>
</html>

and does not work, the screen is blank, but if i change:
read: "http://mykey@localhost/orion/api/customers/1"
with:
read: "1.xml"
that contains de content of "http://mykey@localhost/orion/api/customers/1", that's:
<prestashop>
    <customer>
        <id>1</id>
        <id_default_group xlink:href="http://localhost/orion/api/groups/1">1</id_default_group>
        <newsletter_date_add/>
        <ip_registration_newsletter/>
        <last_passwd_gen readonly="true">2012-06-09 09:05:45</last_passwd_gen>
        <secure_key readonly="true">47ce86627c1f3c792a80773c5d2deaf8</secure_key>
        <deleted>0</deleted>
        <passwd>6f9c2e625d0cc6fe573231821c23859b</passwd>
        <lastname>DOE</lastname>
        <firstname>John</firstname>
        <email>pub@prestashop.com</email>
        <note/>
        <id_gender>1</id_gender>
        <birthday>1970-01-15</birthday>
        <newsletter>1</newsletter>
        <optin>1</optin>
        <active>1</active>
        <is_guest>0</is_guest>
        <date_add readonly="true">2012-06-09 02:05:45</date_add>
        <date_upd readonly="true">2012-06-09 02:05:45</date_upd>
        <associations>
            <groups node_type="group">
                <group xlink:href="http://localhost/orion/api/groups/1">
                    <id>1</id>
                </group>
            </groups>
        </associations>
    </customer>
</prestashop>
it shows one row in the grid.

What can be wrong?. the server is on and the requested page is served in form of xml, but i don't know how to make it work. help me.

Thanks

1 Answer, 1 is accepted

Sort by
0
Thomas
Top achievements
Rank 1
answered on 17 Jul 2012, 01:57 PM
If someone could comment on this, it would be very helpful.
Tags
Data Source
Asked by
Jose
Top achievements
Rank 1
Answers by
Thomas
Top achievements
Rank 1
Share this question
or