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

ListView not Binding to JSON

3 Answers 144 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Ryan Lege
Top achievements
Rank 1
Ryan Lege asked on 14 Sep 2012, 11:11 AM
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>
</div>


<script>
    $(document).ready(function() {


        var sharedDataSource = new kendo.data.DataSource({
            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
        });

        $("#listView").kendoListView({
            dataSource: sharedDataSource,
            template: "<li>${Title}</li>"
        });
    });
</script>

3 Answers, 1 is accepted

Sort by
0
Accepted
Vladimir Iliev
Telerik team
answered on 19 Sep 2012, 10:17 AM
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!
0
Ryan Lege
Top achievements
Rank 1
answered on 19 Sep 2012, 03:03 PM
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?
0
David
Top achievements
Rank 1
answered on 06 Dec 2012, 02:22 PM
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);


Tags
ListView
Asked by
Ryan Lege
Top achievements
Rank 1
Answers by
Vladimir Iliev
Telerik team
Ryan Lege
Top achievements
Rank 1
David
Top achievements
Rank 1
Share this question
or