Kendo UI Listview filter
How to filter the Kendo UI ListView using a 'contains' style search. Example for RBW.
HTML
<link rel="stylesheet" href="http://cdn.kendostatic.com/2014.3.1411/styles/kendo.common.min.css">
<link rel="stylesheet" href="http://cdn.kendostatic.com/2014.3.1411/styles/kendo.default.min.css">
<link rel="stylesheet" href="http://cdn.kendostatic.com/2014.3.1411/styles/kendo.dataviz.min.css">
<link rel="stylesheet" href="http://cdn.kendostatic.com/2014.3.1411/styles/kendo.dataviz.default.min.css">
<script src="http://cdn.kendostatic.com/2014.3.1411/js/kendo.all.min.js"></script>
<div class="panel panel-default">
<div class="panel-heading form-inline">
<div class="form-group">
<label for='search-term'>Search </label>
<input type="text" id="search-term"/>
</div>
<div class="form-group">
<label for='search-term'>Group </label>
<select id="groupIds" class="form-control">
<option>All</option>
<option>Beverages</option>
<option>Condiments</option>
<option>Produce</option>
<option>Meat/Poultry</option>
<option>Seafood</option>
</select>
</div>
</div>
<div class="panel-body">
<div class="demo-section">
<div id="listView"></div>
<div id="pager" class="k-pager-wrap"></div>
</div>
</div>
</div>
<script id="template" type="text/x-kendo-template">
<div class="product">
<h3>#:ProductName#</h3>
<p>#:Category.CategoryName# - #:QuantityPerUnit#</p>
<p>#:kendo.toString(UnitPrice, "c")#</p>
</div>
</script>
CSS
html { font-size: 12px; font-family: Arial, Helvetica, sans-serif; }
.demo-section {
width: 400px;
/*margin: 20px auto;*/
border: 0;
background: none;
}
#listView {
padding: 10px 5px;
margin-bottom: -1px;
min-height: 510px;
}
.product {
position: relative;
width: auto;
}
.product h3 {
}
.k-listview:after {
content: ".";
display: block;
height: 0;
clear: both;
visibility: hidden;
}
JavaScript
var dataSource = new kendo.data.DataSource({
pageSize: 9,
transport: {
read: {
//using jsfiddle echo service to simulate JSON endpoint
url: "/echo/json/",
dataType: "json",
type: "POST",
data: {
// /echo/json/ echoes the JSON which you pass as an argument
json: JSON.stringify([{"ProductID":1,"ProductName":"Chai","SupplierID":1,"CategoryID":1,"QuantityPerUnit":"10 boxes x 20 bags","UnitPrice":18,"UnitsInStock":39,"UnitsOnOrder":0,"ReorderLevel":10,"Discontinued":false,"Category":{"CategoryID":1,"CategoryName":"Beverages","Description":"Soft drinks, coffees, teas, beers, and ales"}},{"ProductID":2,"ProductName":"Chang","SupplierID":1,"CategoryID":1,"QuantityPerUnit":"24 - 12 oz bottles","UnitPrice":19,"UnitsInStock":17,"UnitsOnOrder":40,"ReorderLevel":25,"Discontinued":false,"Category":{"CategoryID":1,"CategoryName":"Beverages","Description":"Soft drinks, coffees, teas, beers, and ales"}},{"ProductID":3,"ProductName":"Aniseed Syrup","SupplierID":1,"CategoryID":2,"QuantityPerUnit":"12 - 550 ml bottles","UnitPrice":10,"UnitsInStock":13,"UnitsOnOrder":70,"ReorderLevel":25,"Discontinued":false,"Category":{"CategoryID":2,"CategoryName":"Condiments","Description":"Sweet and savory sauces, relishes, spreads, and seasonings"}},{"ProductID":4,"ProductName":"Chef Anton's Cajun Seasoning","SupplierID":2,"CategoryID":2,"QuantityPerUnit":"48 - 6 oz jars","UnitPrice":22,"UnitsInStock":53,"UnitsOnOrder":0,"ReorderLevel":0,"Discontinued":false,"Category":{"CategoryID":2,"CategoryName":"Condiments","Description":"Sweet and savory sauces, relishes, spreads, and seasonings"}},{"ProductID":5,"ProductName":"Chef Anton's Gumbo Mix","SupplierID":2,"CategoryID":2,"QuantityPerUnit":"36 boxes","UnitPrice":21.35,"UnitsInStock":0,"UnitsOnOrder":0,"ReorderLevel":0,"Discontinued":true,"Category":{"CategoryID":2,"CategoryName":"Condiments","Description":"Sweet and savory sauces, relishes,...