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

Binding RadGrid datasource to Atom data issue with namespace

1 Answer 73 Views
Grid for HTML
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Allan
Top achievements
Rank 1
Allan asked on 04 Apr 2013, 07:00 AM
Folks, I've got data coming out of a Sharepoint 2013 list that for now I have to receive in default atom feed format. I'm trying to bind this to a simple grid control but don't know the syntax to use to get at subelements - I've tried everything that is Xpath like but with no luck.

 

var grid1Ctrl = new Telerik.UI.RadGrid(document.getElementById("grid1"), {
    dataSource: {
        transport:
        {
            read: {
                url: "test.xml"
            }
        },
        schema: {
            // specify the the schema is XML
            type: "xml",
            data: "/feed/entry/content",
            model: {
                fields: {
                    title: "What to put here to get at Hello World text of <m:properties><d:Title>Hello World</d:Title></m:properties>",
                }
            }
        }
    },
    height: 300
});

 

Here's the data in test.xml.
<?xml version="1.0" encoding="utf-8"?><feed xml:base="https://microsoft.sharepoint.com/someurl/_api/" xmlns="http://www.w3.org/2005/Atom" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns:georss="http://www.georss.org/georss" xmlns:gml=" /><updated>2013-04-02T17:20:21Z</updated><entry m:etag="&quot;24&quot;"><id>40453566-9fd4-4072-9123-3287afcc007c</id><category term="SP.Data.Blah" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" /><link rel="edit" href="Web/Lists(guid'c9e78bb7-103a-441b-a31e-b8204e8e890f')/Items(1)" /><title /><updated>2013-04-02T17:20:21Z</updated><author><name /></author><content type="application/xml"><m:properties><d:Title>Hello World</d:Title></m:properties></content></entry></feed>

1 Answer, 1 is accepted

Sort by
0
Accepted
Tsvetina
Telerik team
answered on 04 Apr 2013, 07:52 AM
Hi Allan,

The problem that you are experiencing is due to the structure of the XML file. The DataSource does not support binding to XML with namespaces (e.g. <d:Title>). 
The options in this scenario are to either get the server to return flat XML, without namespaces, or to consume the data in JSON format.

To try out a working version of this scenario, use this RadGrid definition:

var grid1Ctrl = new Telerik.UI.RadGrid(document.getElementById("grid1"), {
    dataSource: {
        transport:
        {
            read: {
                url: "test.xml"
            }
        },
        schema: {
            // specify the the schema is XML
            type: "xml",
            data: "/feed/entry/content/properties",
            model: {
                fields: {
                    title: "Title/text()"
                }
            }
        }
    },
    columns: [
        { field: "title" }
    ],
    height: 300
});

and the following sample modification of the XML:
<?xml version="1.0" encoding="utf-8"?>
    <id>340b8e28-b134-4933-952f-21473036f4bb</id>
    <title />
    <updated>2013-04-02T17:20:21Z</updated>
    <entry m:etag=""24"">
        <id>40453566-9fd4-4072-9123-3287afcc007c</id>
        <category term="SP.Data.Blah" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
        <link rel="edit" href="Web/Lists(guid'c9e78bb7-103a-441b-a31e-b8204e8e890f')/Items(1)" />
        <title />
        <updated>2013-04-02T17:20:21Z</updated>
        <author>
            <name />
        </author>
        <content type="application/xml">
            <properties>
                <Title>Hello World</Title>
            </properties>
        </content>
    </entry>
</feed>


Kind regards,
Tsvetina
the Telerik team
Have a suggestion or face a problem - you can use the Ideas & Feedback portal to submit ideas, feedback and vote for them.
Tags
Grid for HTML
Asked by
Allan
Top achievements
Rank 1
Answers by
Tsvetina
Telerik team
Share this question
or