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

Data not displaying in ListView when working with OData v3

4 Answers 162 Views
ListView (Mobile)
This is a migrated thread and some comments may be shown as answers.
Abhishek
Top achievements
Rank 1
Abhishek asked on 18 May 2012, 03:54 AM
Hi 

I am starting with Kendo UI. I have an exisiting OData Service at http://enservice.indiamvp.net/EventNetworkingService.svc/Cities that is based on Odata v3. 

I am trying to display the cityname in a Mobile ListView. I have set up my datasource as follows:
var speakerData = new kendo.data.DataSource(
                {
                    type: "odata",
                    transport: {
                        read: {
                            // the remote service url
                            url: "http://enservice.indiamvp.net/EventNetworkingService.svc/Cities",
                            dataType: "jsonp",
                            data: {
                                Accept: "application/json"
                            }
                        }
                    },
                    serverfiltering: false,
                    serverPaging: true,
                    pageSize: 10,
                    batch: false,
                    schema: {
                    data: "d",
                        model: {
                            id: "CityID",
                            fields: {
                                CityID: { type: "number" },
                                CityName: { type: "string" }
                            }
                        }


                    }
                }
                );

To initialise the ListView I am using the following:

                $("#speakersView").kendoMobileListView(
                {
                    template: "<strong>${speakerData.CityName}</strong><br/>",
                    dataSource: speakerData.read()
                }
                );

Both the functions are in <head> element and not in the $document.ready function. I am using data-init on the view. Checking from Chrome Dev Tools, I can see that the JSON data is downloaded. 
However, nothing gets displayed on the ListView. Stepping through the JS i see that there is a exception getting generated: "speakerData is not defined" pointing to the fact the maybe the DataSource is not initialised properly.

Can someone recommend on what I could be doing incorrectly?

Thanks
Abhishek

4 Answers, 1 is accepted

Sort by
0
Petyo
Telerik team
answered on 18 May 2012, 08:16 AM
Hi,

Can you please try using 

$("#speakersView").kendoMobileListView({
          template: "<strong>${speakerData.CityName}</strong><br/>",
          dataSource: speakerData
      });

Kind regards,
Petyo
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Abhishek
Top achievements
Rank 1
answered on 18 May 2012, 11:26 AM

Thanks for sending detailed instructions about the setting the error correct. As it happened, it was a case of misconfiguration. I took the following steps to set the DataSource correctly:
1. Set dataSource : speakerData // no .read()
template: "${CityName}" // no prefix here.

 

0
Saurav
Top achievements
Rank 1
answered on 18 May 2012, 11:49 AM
@ Abhishek,

Did you already worked with asmx webserive json data? 
0
Abhishek
Top achievements
Rank 1
answered on 18 May 2012, 12:05 PM
Well i was using Odata via WCF Data Services. there was no involvement of ASMX service with JSON Support.
Tags
ListView (Mobile)
Asked by
Abhishek
Top achievements
Rank 1
Answers by
Petyo
Telerik team
Abhishek
Top achievements
Rank 1
Saurav
Top achievements
Rank 1
Share this question
or