Update datasource

by OnaBai

HTML

<script src="http://cdn.kendostatic.com/2013.1.319/js/jquery.min.js"></script>
<script src="http://cdn.kendostatic.com/2013.1.319/js/kendo.all.min.js"></script>
<link rel="stylesheet" href="http://cdn.kendostatic.com/2013.1.319/styles/kendo.common.min.css">
<link rel="stylesheet" href="http://cdn.kendostatic.com/2013.1.319/styles/kendo.default.min.css">
<button id="button" class="k-button">Update</button>
<div id="listView">
</div>

CSS

.product1 {
    background-color: #ffff00;
}

h3 { 
    font-size: 2em;
}

JavaScript

$("#listView").kendoListView({
    dataSource: {
        data: [
            { text: "India", name: "product" },
            { text: "Gujarat", name: "product1" },
            { text: "Surat", name: "product" }
        ]
    },
    template  : "<div class='my-list ${name}'><h3>${text}</h3></div>"
});
$("#button").on("click", function () {
    var list = $("#listView").data("kendoListView");
    list.dataSource.data([
        { text: "Bulgaria", name: "product" },
        { text: "Spain", name: "product" },
        { text: "USA", name: "product" }
    ])
});