0

I am doing a kendo mobile application and I'm trying to bind data from database for listing using json call. I tried with the following code,but its not working Pls help me with this...thanks in advance...

my code is here:

        $(document).ready(function () {

            var dataSource = new kendo.data.DataSource({
                transport: {
                    read: {
                        type: "POST",
                        url: "WebService/listing.php",
                        contentType: 'application/json; charset=utf-8',
                        datatype: "json"
                    }
                }
            });

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

            dataSource.read();
            console.log(dataSource.view());

        });
Nishanth Nair
  • 2,975
  • 2
  • 19
  • 22
user1254613
  • 25
  • 1
  • 2
  • 4

1 Answers1

0

You could try to use the changefunction of the dataSource directly:

var dataSource = new kendo.data.DataSource({
    transport: {
        read: {
            type: "POST",
            url: "WebService/listing.php",
            contentType: 'application/json; charset=utf-8',
            datatype: "json"
        }
    },
    change: function() {
        $("#content").html(kendo.render(template, this.view()));
    }
});

Just some things to consider:

  • I'm assuming your JSON is correct
  • You're sure you use POST to get the data
  • your template is as well defined correctly
  • You're calling dataSource.read() AFTER the data is loaded (to make sure you're doing this, call read() within $(document).ready(function(){dataSource.read();}); and define the dataSource itself first

    I guess the last point is the most crucial ;)

    That's all I am doing, so if it doesn't work that way there might be some mistake in the data format itself or in the template definition. Anything like console errors?

    Cheers

  • d2uX
    • 241
    • 2
    • 14