ListView not Binding to JSON

4 posts, 1 answers
  1. Ryan Lege
    Ryan Lege avatar
    42 posts
    Member since:
    Sep 2008

    Posted 14 Sep 2012 Link to this post

    I cannot get this to bind for some reason. I have attached the Fiddler response JSON data as evidence that it is coming in.

    <div class="k-content">
        <div id="listView"></div>

        $(document).ready(function() {

            var sharedDataSource = new{
                transport: {
                    type: "odata",
                    read: {
                        url: "DataService" + "/Events()?$filter=(((StartDate le datetime'2012-09-14') and (EndDate ge datetime'2012-09-14')) or ((StartDate le datetime'2012-09-21') and (EndDate ge datetime'2012-09-21'))) or (((((StartDate ge datetime'2012-09-14') and (EndDate le datetime'2012-09-21')) or ((StartDate le datetime'2012-09-14') and (EndDate ge datetime'2012-09-21'))) and (not Inactive)) and Viewable)",
                        contentType: "application/json; charset=utf-8",
                        type: "GET",
                        dataType: "jsonp",
                        data: {
                            Accept: "application/json"
                pageSize: 12

                dataSource: sharedDataSource,
                template: "<li>${Title}</li>"
  2. Answer
    Vladimir Iliev
    Vladimir Iliev avatar
    2206 posts

    Posted 19 Sep 2012 Link to this post

    Hi Benjamin,

    We cannot be sure what exactly is going wrong. The dataSource is configured for JSONP but from the response it's not getting clear if you are actually returning JSON or JSONP.

    Please provide more information about what data you are returning from your DataService or prepare example where the issue is reproduced - hopefully this will help us pinpoint the exact reason for this behaviour.

    Kind Regards,
    Vladimir Iliev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. Ryan Lege
    Ryan Lege avatar
    42 posts
    Member since:
    Sep 2008

    Posted 19 Sep 2012 Link to this post

    I'm not sure what is happening now, but JSONP returns xml not JSON and when I change the Datatype to json then it will not even bother trying to get the data according to Fiddler! How would you debug this?
  4. David
    David avatar
    4 posts
    Member since:
    Jun 2012

    Posted 06 Dec 2012 Link to this post

    Hi, not sure if anone is still having this problem but I finally worked out why my json wasn't binding with the listview.

    try adding JsonRequestBehavior.AllowGet to your return i.e. return Json(result, JsonRequestBehavior.AllowGet);

Back to Top