ListView refresh not rendering

3 posts, 1 answers
  1. Phil H.
    Phil H. avatar
    88 posts
    Member since:
    Nov 2008

    Posted 14 Jun 2014 Link to this post

    Hi:
    I am updating after initial rendering.  I am manually modifying the datasource data as follows:  
    <div id ="listView2"></div>
    <script>
        $("#listView2").kendoListView({
            dataSource: { data: [] },
            template: "<div>#:name#</div>"
        });
        var listView2 = $("#listView2").data("kendoListView");
        listView2.dataSource.data = [ { name: "Jane Doe" }, { name: "John Doe" }];
        listView2.refresh();
    </script>
    I expected the refresh after the data assignment to render the ListView widget, but the value of length is never set when refresh is called.

    Phil
  2. Answer
    Alexander Valchev
    Admin
    Alexander Valchev avatar
    2875 posts

    Posted 17 Jun 2014 Link to this post

    Hi Phil,

    Please use the data method of the dataSource and the ListView will automatically update.
    listView2.dataSource.data([{ name: "Jane Doe" }, { name: "John Doe" }]);


    Regards,
    Alexander Valchev
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  3. Kendo UI is VS 2017 Ready
  4. Phil H.
    Phil H. avatar
    88 posts
    Member since:
    Nov 2008

    Posted 17 Jun 2014 Link to this post

    Hi Alexander:
    <div id ="listView2" class="k-list-container" style="width: 200px;"></div>
    <script>
        $("#listView2").kendoListView({
            dataSource: { data: [{ name: "Ralph Doe" }, { name: "ZZZZ Zoe" }] },
            template: "<div class='k-item'>#:name#</div>",
            selectable: true
        });
        var listView2 = $("#listView2").data("kendoListView");
        listView2.dataSource.data( [{ name: "Jane Doe" }, { name: "John Doe" }, { name: "Andrea Doe" }] );
        listView2.refresh();
    </script>
    Thanks, the above works great!
    Phil
Back to Top