Widget initialization

6 posts, 1 answers
  1. Kakone
    Kakone avatar
    68 posts
    Member since:
    Jan 2010

    Posted 22 Mar 2012 Link to this post

    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.
  2. Answer
    Petyo
    Admin
    Petyo avatar
    2444 posts

    Posted 23 Mar 2012 Link to this post

    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!
  3. Kakone
    Kakone avatar
    68 posts
    Member since:
    Jan 2010

    Posted 23 Mar 2012 Link to this post

    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.
  4. Agnes
    Agnes avatar
    1 posts
    Member since:
    Sep 2008

    Posted 02 Apr 2012 Link to this post

    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
  5. Alexander Valchev
    Admin
    Alexander Valchev avatar
    2895 posts

    Posted 05 Apr 2012 Link to this post

    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!
  6. Michael
    Michael avatar
    7 posts
    Member since:
    Mar 2012

    Posted 03 May 2012 Link to this post

    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.
Back to Top