HTML5 developing mobile Web Apps--sencha Touch (10)

Source: Internet
Author: User

We visualize the data in order to do some manipulation of the data.

Here 's a look at the sorting and searching features of DataView.

Mastering these two skills allows the data in the written data interface to be sorted according to the requirements, to be able to perform the search display function of the data.

First, sort

When we want to sort by a field of data, we can call the sort method:

Store.sort (' LastName ', ' ASC ');

Of Store is our well-defined data warehouse, called Sort method to sort. the sort method passes in two parameters. The first parameter is sorted by which field, the second is ascending or descending.

Assuming that you want to sort multiple fields, you can run code such as the following:

Store.sorters.add (New Ext.util.Sorter ({property: ' FirstName ', direction: ' ASC '}); Store.sort ();

By using the sorters.add method, you can add multiple sorting criteria, and finally call the sort () method, and the order in which the sequencing is run is determined by the order of accession.

We can define an option box in the interface, sort by the user's options, by setting the value for each option . The value values are passed into the sort method and sorted according to the requirements.

Second, search

There are methods for filtering data in the Data Warehouse in DataView. The code is as follows:

Store.filter (' LastName ', ' Tom ');

This sentence means that the data is filtered out. The value of its lastName property is Tom.

Similarly. Suppose we want to implement the user's search function. Define a search box to pass the value entered by the user into the filter function. It is also possible to filter by multiple filters (data that is set up for multiple filter times will be selected). Note that you must run the search cleanup operation before each run of the search operation:

Store.clearfilter ();

This ensures that there is no previous search disturbance for each search.

If it's not clear. The content displayed is the intersection of multiple search results (very likely no results).

HTML5 developing mobile Web Apps--sencha Touch (10)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.