This is a migrated thread and some comments may be shown as answers.
Widget initialization
5 Answers 91 Views
This is a migrated thread and some comments may be shown as answers.
Kakone
Top achievements
Rank 1
Kakone asked on 22 Mar 2012, 06:24 PM
Hello,

I initialize a Kendo UI Mobile ListView like this :
var projects = new kendo.data.DataSource({
  type: "odata",
  transport: { read: "http://localhost:50486/WcfDataService.svc/Projects" }               
});
$("#projectsListView").kendoMobileListView({
  dataSource: projects,
  style : "inset",
  template: "${Number} - ${Label}",
});
In this case, it works well.

But, if I use the syntax below, it doesn't work at all (no data displayed). Why ?
$("#projectsListView").kendoMobileListView();
var lv = $("#projectsListView").data("kendoMobileListView");
lv.options.template = "${Number} - ${Label}";
lv.options.style = "inset";
lv.dataSource = projects;
lv.refresh();

Cordially,
Kakone.

5 Answers, 1 is accepted

Sort by
0
Accepted
Petyo
Telerik team
answered on 23 Mar 2012, 08:41 AM
Hi,

This initialization is not supported, indeed. If it works, it is by accident. Can you please share why are you trying to use it? 

All the best,
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
Kakone
Top achievements
Rank 1
answered on 23 Mar 2012, 10:20 AM
Hi,

I'm just doing some tests and I wanted to know if I can modify the dataSource of the listview after it is initialized. I thinked to have a layout with a listView and set the template and the datasource according to a choice of the user. This is not very problematic because I can do it in other way, I just wondered why it was not possible to do that.

Cordially,
Kakone.
0
Agnes
Top achievements
Rank 1
answered on 03 Apr 2012, 04:56 AM
Hi,
 I had similar problem. When I tried to refresh a dataSource which is linked to a MobileListView, the dataSource seemed refreshed (ie it calls server to fetch data) but the listview was not refreshed.
var dataSource = $("#active-loan-listview").data("kendoMobileListView").dataSource;
 dataSource.query({
                page: 2,
                pageSize: 10
             });

Another question about dataSource. How do you get the current page of the dataSource?

Thanks,
Agnes
0
Alexander Valchev
Telerik team
answered on 05 Apr 2012, 01:48 PM
Hello Agnes,

By default when the dataSource is changed, the widget that is bound to it will automatically refresh. Probably there is a problem connected with the query method. Could you please confirm that after calling the query function the server is sending a response with data?

Regarding to your second question, you can use the page method in order to retrieve current page index.

Kind regards,
Alexander Valchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Michael
Top achievements
Rank 1
answered on 03 May 2012, 04:03 PM
This is an old thread but I wanted to chime in and say that I am having a similar issue... changing the datasource does not cause the listview to refresh.

It's not even attempting to query the server, even if you manually call refresh().

No errors thrown, simply doesn't work.
Asked by
Kakone
Top achievements
Rank 1
Answers by
Petyo
Telerik team
Kakone
Top achievements
Rank 1
Agnes
Top achievements
Rank 1
Alexander Valchev
Telerik team
Michael
Top achievements
Rank 1
Share this question
or