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

ListView refresh not rendering

2 Answers 139 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Phil H.
Top achievements
Rank 2
Phil H. asked on 14 Jun 2014, 08:50 PM
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 Answers, 1 is accepted

Sort by
0
Accepted
Alexander Valchev
Telerik team
answered on 17 Jun 2014, 04:35 PM
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!
 
0
Phil H.
Top achievements
Rank 2
answered on 17 Jun 2014, 10:33 PM
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
Tags
ListView
Asked by
Phil H.
Top achievements
Rank 2
Answers by
Alexander Valchev
Telerik team
Phil H.
Top achievements
Rank 2
Share this question
or