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

Binding to JSON data

2 Answers 209 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
AP
Top achievements
Rank 1
Veteran
AP asked on 22 Nov 2011, 05:24 PM
I'm trying to use the datasource to populate a grid, binding to some JSON data , supplied via an aspx page. I'm not sure if the data is in the correct format (although it is valid JSON sysntax) , or if I need to alter the definition of the datasource, but quite frankly I find the documentation far from helpful.

Do I need to change my code that's producing the JSON data (it's using a LINQ source, exporting a list to JSON using the jayrock library), or do I need to define the fields in the datasource? If so, how?

I've got so far:-
<script>
      var dataSource = new kendo.data.DataSource({
          transport: {
              read: {
                  url: "http://localhost:50331/GetPatList.aspx?srch=Benz",
                  dataType: "json",
                  data: {
                  }
              }
          }
      });
  
  </script>

But so far nothing happens ( is there an easy way to see if a datasource is getting any data without first binding it to anything - or a good way to debug it?).

The JSON data I'm providing in my aspx page looks like (it's fictional data for development purposes):-
[{"surName":"Benzene","foreName":"Alabaster","dOB":"1954-09-30T00:00:00.0000000+01:00"},{"surName":"Benzene","foreName":"Alabaster","dOB":"1940-01-03T00:00:00.0000000+00:00"},{"surName":"Benzene","foreName":"Alabaster","dOB":"1925-03-15T00:00:00.0000000+00:00"},{"surName":"Benzene","foreName":"Alphonso","dOB":"1960-12-21T00:00:00.0000000+00:00"},{"surName":"Benzene","foreName":"Alphonso","dOB":"1972-02-04T00:00:00.0000000+00:00"},{"surName":"Benzene","foreName":"Andrew","dOB":"1985-07-18T00:00:00.0000000+01:00"},{"surName":"Benzene","foreName":"Andrew","dOB":"1939-09-14T00:00:00.0000000+01:00"},{"surName":"Benzene","foreName":"Andrew","dOB":"1961-06-25T00:00:00.0000000+01:00"},{"surName":"Benzene","foreName":"Andrew","dOB":"1948-12-31T00:00:00.0000000+00:00"},{"surName":"Benzene","foreName":"Anya","dOB":"1978-02-01T00:00:00.0000000+00:00"},{"surName":"Benzene","foreName":"Anya","dOB":"1924-08-12T00:00:00.0000000+01:00"},{"surName":"Benzene","foreName":"Aphrodite","dOB":"1932-03-11T00:00:00.0000000+00:00"},{"surName":"Benzene","foreName":"Arbuthnot","dOB":"1930-07-19T00:00:00.0000000+01:00"},{"surName":"Benzene","foreName":"Ariarna","dOB":"1973-10-14T00:00:00.0000000+01:00"},{"surName":"Benzene","foreName":"Ariarna","dOB":"1946-02-04T00:00:00.0000000+00:00"},{"surName":"Benzene","foreName":"Armand","dOB":"1956-09-14T00:00:00.0000000+01:00"},{"surName":"Benzene","foreName":"Armand","dOB":"1976-06-05T00:00:00.0000000+01:00"},{"surName":"Benzene","foreName":"Armarni","dOB":"2010-01-04T00:00:00.0000000+00:00"},{"surName":"Benzene","foreName":"Armarni","dOB":"2000-09-16T00:00:00.0000000+01:00"},{"surName":"Benzene","foreName":"Arnie","dOB":"1924-08-21T00:00:00.0000000+01:00"},{"surName":"Benzene","foreName":"Arnie","dOB":"1998-11-23T00:00:00.0000000+00:00"},{"surName":"Benzene","foreName":"Arnie","dOB":"1972-05-31T00:00:00.0000000+01:00"},{"surName":"Benzene","foreName":"Arnie","dOB":"1922-09-08T00:00:00.0000000+01:00"},{"surName":"Benzene","foreName":"Arnold","dOB":"1980-07-09T00:00:00.0000000+01:00"},{"surName":"Benzene","foreName":"Arnold","dOB":"1967-08-28T00:00:00.0000000+01:00"},{"surName":"Benzene","foreName":"Arthurs","dOB":"2002-07-11T00:00:00.0000000+01:00"},{"surName":"Benzene","foreName":"Arthurs","dOB":"1947-06-09T00:00:00.0000000+01:00"},{"surName":"Benzene","foreName":"Banzai","dOB":"1967-11-29T00:00:00.0000000+00:00"},{"surName":"Benzene","foreName":"Banzai","dOB":"1941-09-17T00:00:00.0000000+01:00"},{"surName":"Benzene","foreName":"Banzai","dOB":"1964-12-09T00:00:00.0000000+00:00"},{"surName":"Benzene","foreName":"Basil","dOB":"1994-02-16T00:00:00.0000000+00:00"},{"surName":"Benzene","foreName":"Basil","dOB":"1969-07-27T00:00:00.0000000+01:00"},{"surName":"Benzene","foreName":"Bethany","dOB":"1975-12-11T00:00:00.0000000+00:00"},{"surName":"Benzene","foreName":"Biff","dOB":"1936-08-23T00:00:00.0000000+01:00"},{"surName":"Benzene","foreName":"Biff","dOB":"1969-10-24T00:00:00.0000000+01:00"},{"surName":"Benzene","foreName":"Biff","dOB":"1974-01-19T00:00:00.0000000+00:00"},{"surName":"Benzene","foreName":"Bongo","dOB":"1960-02-08T00:00:00.0000000+00:00"},{"surName":"Benzene","foreName":"Bongo","dOB":"1969-09-08T00:00:00.0000000+01:00"},{"surName":"Benzene","foreName":"Bongo","dOB":"1948-08-01T00:00:00.0000000+01:00"},{"surName":"Benzene","foreName":"Bongo","dOB":"1991-08-15T00:00:00.0000000+01:00"},{"surName":"Benzene","foreName":"Bongo","dOB":"1942-11-03T00:00:00.0000000+00:00"},{"surName":"Benzene","foreName":"Brenda","dOB":"1946-10-20T00:00:00.0000000+01:00"},{"surName":"Benzene","foreName":"Brenda","dOB":"1947-01-22T00:00:00.0000000+00:00"},{"surName":"Benzene","foreName":"Brenda","dOB":"1989-08-29T00:00:00.0000000+01:00"},{"surName":"Benzene","foreName":"Brett","dOB":"1941-10-16T00:00:00.0000000+01:00"},{"surName":"Benzene","foreName":"Brick","dOB":"2007-05-08T00:00:00.0000000+01:00"},{"surName":"Benzene","foreName":"Brick","dOB":"1988-09-29T00:00:00.0000000+01:00"},{"surName":"Benzene","foreName":"Bruce","dOB":"1921-01-13T00:00:00.0000000+00:00"},{"surName":"Benzene","foreName":"Bruce","dOB":"2010-03-01T00:00:00.0000000+00:00"},{"surName":"Benzene","foreName":"Ceejay","dOB":"2000-08-25T00:00:00.0000000+01:00"},{"surName":"Benzene","foreName":"Ceejay","dOB":"1979-10-08T00:00:00.0000000+01:00"},{"surName":"Benzene","foreName":"Cesarie","dOB":"2010-01-02T00:00:00.0000000+00:00"},{"surName":"Benzene","foreName":"Cesarie","dOB":"1938-04-15T00:00:00.0000000+01:00"},{"surName":"Benzene","foreName":"Charles","dOB":"1940-07-24T00:00:00.0000000+01:00"},{"surName":"Benzene","foreName":"Charles","dOB":"1958-08-28T00:00:00.0000000+01:00"},{"surName":"Benzene","foreName":"Charlotte","dOB":"1972-04-26T00:00:00.0000000+01:00"},{"surName":"Benzene","foreName":"Chelsea","dOB":"1957-10-17T00:00:00.0000000+01:00"}]


Thanks

2 Answers, 1 is accepted

Sort by
0
Accepted
Atanas Korchev
Telerik team
answered on 24 Nov 2011, 09:14 AM
Hello Ap,

 Is the aspx page requested at all? You can check this with Fiddler (for IE), FireBug (for Firefox) or Chrome developer tools. Do you see any JavaScript errors? Providing the grid declaration would be helpful too.

Best wishes,
Atanas Korchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
AP
Top achievements
Rank 1
Veteran
answered on 28 Nov 2011, 04:20 PM
Thanks,

I used fiddler, and the aspx page still had the header information in it.

I've removed this, and it now works.
Tags
Data Source
Asked by
AP
Top achievements
Rank 1
Veteran
Answers by
Atanas Korchev
Telerik team
AP
Top achievements
Rank 1
Veteran
Share this question
or