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

odata and kendo datasource and grid

1 Answer 727 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
luke johnson
Top achievements
Rank 1
luke johnson asked on 27 Apr 2012, 04:59 PM
I have a class: PeopleService that returns IQueryable list of People

public class PeopleService
    {
        List<Person> people = new List<Person>()
        {
            new Person(50, "Fred"),
            new Person(30, "John"),
            new Person(26, "Andrew"),
            new Person(24, "Xaier"),
            new Person(5, "Mark"),
            new Person(6, "Cameron"),
        };
 
        public IQueryable<Person> People
        {
            get { return people.AsQueryable<Person>(); }
        }
    }

This is the script that I am using:

<script>
    var myDataSource = {
        type: "odata",
        transport:
    {
        read: "http://localhost:56626/WcfDataService1.svc/People"
    }
    };
 
    $(document).ready(function () {
        $("#grid").kendoGrid({
            dataSource: myDataSource,
            height: 500,
            columns: ["Age", "Name"]
        });
    });
</script>

Here is the url view source of my read:

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
  <title type="text">People</title>
  <id>http://localhost:56626/WcfDataService1.svc/People</id>
  <updated>2012-04-27T15:18:58Z</updated>
  <link rel="self" title="People" href="People" />
  <entry>
    <id>http://localhost:56626/WcfDataService1.svc/People('Fred')</id>
    <title type="text"></title>
    <updated>2012-04-27T15:18:58Z</updated>
    <author>
      <name />
    </author>
    <link rel="edit" title="Person" href="People('Fred')" />
    <category term="WebApplication1.Person" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
    <content type="application/xml">
      <m:properties>
        <d:Age m:type="Edm.Int32">50</d:Age>
        <d:Name>Fred</d:Name>
      </m:properties>
    </content>
  </entry>
  <entry>
    <id>http://localhost:56626/WcfDataService1.svc/People('John')</id>
    <title type="text"></title>
    <updated>2012-04-27T15:18:58Z</updated>
    <author>
      <name />
    </author>
    <link rel="edit" title="Person" href="People('John')" />
    <category term="WebApplication1.Person" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
    <content type="application/xml">
      <m:properties>
        <d:Age m:type="Edm.Int32">30</d:Age>
        <d:Name>John</d:Name>
      </m:properties>
    </content>
  </entry>
  <entry>
    <id>http://localhost:56626/WcfDataService1.svc/People('Andrew')</id>
    <title type="text"></title>
    <updated>2012-04-27T15:18:58Z</updated>
    <author>
      <name />
    </author>
    <link rel="edit" title="Person" href="People('Andrew')" />
    <category term="WebApplication1.Person" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
    <content type="application/xml">
      <m:properties>
        <d:Age m:type="Edm.Int32">26</d:Age>
        <d:Name>Andrew</d:Name>
      </m:properties>
    </content>
  </entry>
  <entry>
    <id>http://localhost:56626/WcfDataService1.svc/People('Xaier')</id>
    <title type="text"></title>
    <updated>2012-04-27T15:18:58Z</updated>
    <author>
      <name />
    </author>
    <link rel="edit" title="Person" href="People('Xaier')" />
    <category term="WebApplication1.Person" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
    <content type="application/xml">
      <m:properties>
        <d:Age m:type="Edm.Int32">24</d:Age>
        <d:Name>Xaier</d:Name>
      </m:properties>
    </content>
  </entry>
  <entry>
    <id>http://localhost:56626/WcfDataService1.svc/People('Mark')</id>
    <title type="text"></title>
    <updated>2012-04-27T15:18:58Z</updated>
    <author>
      <name />
    </author>
    <link rel="edit" title="Person" href="People('Mark')" />
    <category term="WebApplication1.Person" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
    <content type="application/xml">
      <m:properties>
        <d:Age m:type="Edm.Int32">5</d:Age>
        <d:Name>Mark</d:Name>
      </m:properties>
    </content>
  </entry>
  <entry>
    <id>http://localhost:56626/WcfDataService1.svc/People('Cameron')</id>
    <title type="text"></title>
    <updated>2012-04-27T15:18:58Z</updated>
    <author>
      <name />
    </author>
    <link rel="edit" title="Person" href="People('Cameron')" />
    <category term="WebApplication1.Person" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
    <content type="application/xml">
      <m:properties>
        <d:Age m:type="Edm.Int32">6</d:Age>
        <d:Name>Cameron</d:Name>
      </m:properties>
    </content>
  </entry>
 
</feed>

My grid is not returning data:  What am I missing?

1 Answer, 1 is accepted

Sort by
0
Nikolay Rusev
Telerik team
answered on 02 May 2012, 09:22 AM
Hello Luke,

The response should be JSON formatted and the service doesn't seem to be a OData one.

You can find example of Grid bound to OData service here:
https://github.com/telerik/kendo-examples-asp-net/tree/master/grid-odata-crud

There is also another example of WCF service binding:
https://github.com/telerik/kendo-examples-asp-net/tree/master/grid-wcf-crud

Regards,
Nikolay Rusev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Data Source
Asked by
luke johnson
Top achievements
Rank 1
Answers by
Nikolay Rusev
Telerik team
Share this question
or