Book Image

Kendo UI Cookbook

By : Sagar Ganatra
Book Image

Kendo UI Cookbook

By: Sagar Ganatra

Overview of this book

Table of Contents (18 chapters)
Kendo UI Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Filtering the elements in ListView


The ListView widget can contain several list elements, and scrolling through the entire list to get to the desired list element would be time consuming. For example, consider your contacts list; to get to a particular contact, one will have to scroll several times. To obliterate this, you can add a filter and use it to retrieve the desired list element that matches the input text.

How to do it…

Let's consider a flat data source, that is, an array that contains a list of strings:

var listElements = ['Leonardo DiCaprio', 'Johnny Depp', 
                    'Bradley Cooper', 'Al Pacino', 
                    'Tom Cruise','Jude Law',
                    'Robert Downey Jr.', 'Will Smith',
                    'Robert De Niro', 'Christian Bale',
                    'Brad Pitt','Tom Hanks', 
                    'Robert Pattinson', 'Ben Stiller'];

Now when initializing the ListView widget, provide the preceding elements as a dataSource and also include a filterable...