locked
How do I dynamically change the data source of list view

    Question

  • I have a listview that binds to datasource1 and I want to click a button and change it to bind to datasource2...  So, I do this:

            var listview = $(".mylistview")[0].winControl;
            listview.itemDataSource.beginEdits();
            listview.itemDataSource = datasource2;
            listview.itemDataSource.endEdits();
            listview.forceLayout();

    That doesn't work and I end up with an empty listview and a spinner in the middle of the list view (the spinning dots).

    What am I doing wrong?


    www.emadibrahim.com

    Saturday, May 19, 2012 5:44 PM

Answers

  • Here is the fix

    var listview = $(".mylistview")[0].winControl;
    listview.itemDataSource = data2.dataSource;
    listview.groupDataSource = data2.groups.dataSource;
    listview.forceLayout();

    The problem was that I didn't set the groupDataSource...


    www.emadibrahim.com

    Saturday, May 19, 2012 5:51 PM