Ext.ux.ListPaging, Sencha Touch paging of Dataview Lists

Paging of grids in Ext JS is a complete different business than paging of lists in Sencha Touch. We can’t send a large number of records with server requests because we must assume that the user has possibly an expensive (mobile) data contract with his provider. So we have to manage efficiently what we send and how much we send. And only then when server communication is unavoidable.

In this article I will show a sample with the Ext.ux.ListPaging plugin that can be included in the Ext.dataview.List class. We are not going to do anything fancy. A working model that can be a stepping stone for your own demand. To make this sample work no extras are done with styling or extra visuals.

What we require

  • A model (Ext.data.Model)
  • A store (Ext.data.Store)
  • A list (Ext.dataview.List, with disclosure)

Our list pagesize is 3 records in a table of a total of 8 records. That is very small for practice but for this sample it makes a few things easier to show. But I suggest that you don’t use pages that load too many records at once either. The standard pagesize of a store is 25 records.

A simple search with a list

We start with an empty panel consisting of a search component and a List component. Initially no records are loaded. In Ext JS you might start with a loaded grid before the user searches anything. But in Touch I don’t load anything before user action (cheaper).

image

Initial view

Initial display, no records are shown (the Status button has nothing to do with our sample)

image

First records loaded

When “01” is entered it will show 3 records matching the search criteria.

As you can see the plugin is now adding the “Weitere Sätze” (more records) to the list. The plugin has a config setting autoPaging that is set to true. Now a swipe up will automatically load more records to the model.

You can also tap on “Weitere Sätze” and it will also load the additional records.

image

Browsing with swipe

After a swipe (upwards) the server call adds one more record and adds it to the records in the store. The paging plugin adds now the text “Keine weitere Sätze” (no more records).

image

No records found

When something is entered in the search field that would not lead to any results, the plugin’s output is not displayed and the List object will show the text that is entered at the config item: emptyText.  We will hide the plugins output in the callback routine of the store.load method.

The structure of the List

The following code shows the structure of the Ext.dataview.List extension making class Mobile.view.dataview.Artikel. This file would be Artikel.js in the folder  Apps/Mobile/view/dataview/.

Change the names to names that correspond with your own application. Replace the comment with your own actual data. As you can see I am using still a bit of Ext JS alike coding. I am still not so used to the config descriptions in Sencha Touch classes.

Johan van de Merwe
Dedicated to professional software development since 1985. Has worked since 1992 as IT manager in several international operating companies. Since 2007 CEO and Sencha Ext JS web application developer at Enovision GmbH.

Comments

Leave a Reply

Time limit is exhausted. Please reload CAPTCHA.