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

Can't bind the JSON Webserice data to a HTML Table

2 Answers 224 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Naeem
Top achievements
Rank 1
Naeem asked on 05 Jan 2012, 10:40 AM
I am trying to bind JSON data returned from a ASP.Net web service to table, but could not do so.
Here is the code. where i am going wrong ? 

var template = kendo.template($("#template").html());
var dataSource = new kendo.data.DataSource({
        transport: {
            read: {
                type: "POST",
                url: "http://localhost:52300/WebService1.asmx/Movie",
                contentType: 'application/json; charset=utf-8',
                dataType: "json"
            }
        }
    });

dataSource.bind("change", function () {
        $("#movies tbody").html(kendo.render(template, dataSource.view()));
    });

 dataSource.read();


Where as template is , 

<script id="template" type="text/x-kendo-template">
                <tr>
                    <td>#= Rank #</td>
                    <td>#= Rating #</td>
                    <td>#= Year #</td>
                    <td>#= Title #</td>
                </tr>
  </script>


and web service us showing following data , 

<string xmlns="http://tempuri.org/">[{"Rank":5,"Rating":9,"Year":1995,"Title":"Titanic"},{"Rank":2,"Rating":5,"Year":1964,"Title":"Scent "}]</string>

any help please ?

2 Answers, 1 is accepted

Sort by
0
Naeem
Top achievements
Rank 1
answered on 05 Jan 2012, 11:58 AM
Any one out there to help!
0
Rick
Top achievements
Rank 1
answered on 06 Jan 2012, 04:35 AM
I too have struggled with datasource and json, as have a few others it seems. As yet I have not got it to play nice. It seems to be the Achilles heel of Kendo.
Tags
Data Source
Asked by
Naeem
Top achievements
Rank 1
Answers by
Naeem
Top achievements
Rank 1
Rick
Top achievements
Rank 1
Share this question
or