Sencha Documentation

Super classes

As the amount of records increases, the time required for the browser to render them increases. Paging is used to reduce the amount of data exchanged with the client. Note: if there are more records/rows than can be viewed in the available screen area, vertical scrollbars will be added.

Paging is typically handled on the server side (see exception below). The client sends parameters to the server side, which the server needs to interpret and then respond with the appropriate data.

Ext.toolbar.PagingToolbar is a specialized toolbar that is bound to a Ext.data.Store and provides automatic paging control. This Component loads blocks of data into the store by passing paramNames used for paging criteria.

PagingToolbar is typically used as one of the Grid's toolbars:

Ext.tip.QuickTips.init(); // to display button quicktips

var myStore = new Ext.data.Store({
    reader: new Ext.data.JsonReader({
        totalProperty: 'results', 
        ...
    }),
    ...
});

var myPageSize = 25;  // server script should only send back 25 items at a time

var grid = new Ext.grid.GridPanel({
    ...
    store: myStore,
    dockedItems: [
        new Ext.toolbar.PagingToolbar({
            dock: 'bottom',
            {@link #store: myStore,       // grid and PagingToolbar using same store
            displayInfo: true,
            pageSize: myPageSize,
            prependButtons: true,
            items: [
                'text 1'
            ]
        });
    ]
});

To use paging, pass the paging requirements to the server when the store is first loaded.

store.load({
    params: {
        // specify params for the first page load if using paging
        start: 0,          
        limit: myPageSize,
        // other params
        foo:   'bar'
    }
});

If using store's autoLoad configuration:

var myStore = new Ext.data.Store({
    autoLoad: {params:{start: 0, limit: 25}},
    ...
});

The packet sent back from the server would have this form:

{
    "success": true,
    "results": 2000, 
    "rows": [ // *Note: this must be an Array 
        { "id":  1, "name": "Bill", "occupation": "Gardener" },
        { "id":  2, "name":  "Ben", "occupation": "Horticulturalist" },
        ...
        { "id": 25, "name":  "Sue", "occupation": "Botanist" }
    ]
}

Paging with Local Data

Paging can also be accomplished with local data using extensions:

Config Options

 
afterPageText : String
Customizable piece of the default paging text (defaults to 'of {0}'). Note that this string is formatted using {0} as...
Customizable piece of the default paging text (defaults to 'of {0}'). Note that this string is formatted using {0} as a token that is replaced by the number of total pages. This token should be preserved when overriding this string if showing the total page count is desired.
 
The text displayed before the input item (defaults to 'Page').
The text displayed before the input item (defaults to 'Page').
 
displayInfo : Boolean
true to display the displayMsg (defaults to false)
true to display the displayMsg (defaults to false)
 
displayMsg : String
The paging status message to display (defaults to 'Displaying {0} - {1} of {2}'). Note that this string is formatted ...
The paging status message to display (defaults to 'Displaying {0} - {1} of {2}'). Note that this string is formatted using the braced numbers {0}-{2} as tokens that are replaced by the values for start, end and total respectively. These tokens should be preserved when overriding this string if showing those values is desired.
 
emptyMsg : String
The message to display when no records are found (defaults to 'No data to display')
The message to display when no records are found (defaults to 'No data to display')
 
enableOverflow : Boolean
Defaults to false. Configure true to make the toolbar provide a button which activates a dropdown Menu to show items ...
Defaults to false. Configure true to make the toolbar provide a button which activates a dropdown Menu to show items which overflow the Toolbar's width.
 
firstText : String
The quicktip text displayed for the first page button (defaults to 'First Page'). Note: quick tips must be initialize...
The quicktip text displayed for the first page button (defaults to 'First Page'). Note: quick tips must be initialized for the quicktip to show.
 
lastText : String
The quicktip text displayed for the last page button (defaults to 'Last Page'). Note: quick tips must be initialized ...
The quicktip text displayed for the last page button (defaults to 'Last Page'). Note: quick tips must be initialized for the quicktip to show.
 
layout : String/Object
This class assigns a default layout (layout:'hbox'). Developers may override this configuration option if another lay...
This class assigns a default layout (layout:'hbox'). Developers may override this configuration option if another layout is required (the constructor must be passed a configuration object in this case instead of an array). See Ext.container.Container.layout for additional information.
 
nextText : String
The quicktip text displayed for the next page button (defaults to 'Next Page'). Note: quick tips must be initialized ...
The quicktip text displayed for the next page button (defaults to 'Next Page'). Note: quick tips must be initialized for the quicktip to show.
 
prependButtons : Boolean
true to insert any configured items before the paging buttons. Defaults to false.
true to insert any configured items before the paging buttons. Defaults to false.
 
prevText : String
The quicktip text displayed for the previous page button (defaults to 'Previous Page'). Note: quick tips must be init...
The quicktip text displayed for the previous page button (defaults to 'Previous Page'). Note: quick tips must be initialized for the quicktip to show.
 
refreshText : String
The quicktip text displayed for the Refresh button (defaults to 'Refresh'). Note: quick tips must be initialized for ...
The quicktip text displayed for the Refresh button (defaults to 'Refresh'). Note: quick tips must be initialized for the quicktip to show.
 
store : Ext.data.Store
The Ext.data.Store the paging toolbar should use as its data source (required).
The Ext.data.Store the paging toolbar should use as its data source (required).

Properties

 
paramNames : Object
Deprecated. paramNames should be set in the data store (see Ext.data.Store.paramNames). Object mapping of parameter n...

Deprecated. paramNames should be set in the data store (see Ext.data.Store.paramNames).


Object mapping of parameter names used for load calls, initially set to:

{start: 'start', limit: 'limit'}

Methods

 
add( Mixed arg1, Mixed arg2, Mixed etc. ) : Void
Adds element(s) to the toolbar -- this function takes a variable number of arguments of mixed type and adds them to t...

Adds element(s) to the toolbar -- this function takes a variable number of arguments of mixed type and adds them to the toolbar.


Note: See the notes within Ext.container.Container.add.

Parameters

  • arg1 : Mixed
    The following types of arguments are all valid:
  • arg2 : Mixed
  • etc. : Mixed

Returns

  • Void
 
bind( Ext.data.Store store ) : Void
Binds the paging toolbar to the specified Ext.data.Store (deprecated)
Binds the paging toolbar to the specified Ext.data.Store (deprecated)

Parameters

  • store : Ext.data.Store
    The data store to bind

Returns

  • Void
 
bindStore( Store store, [Boolean initial] ) : Void
Binds the paging toolbar to the specified Ext.data.Store
Binds the paging toolbar to the specified Ext.data.Store

Parameters

  • store : Store
    The store to bind to this toolbar
  • initial : Boolean
    (Optional) true to not remove listeners

Returns

  • Void
 
changePage( Integer page ) : Void
Change the active page
Change the active page

Parameters

  • page : Integer
    The page to display

Returns

  • Void
 
doRefresh : Void
Refresh the current page, has the same effect as clicking the 'refresh' button.
Refresh the current page, has the same effect as clicking the 'refresh' button.
 
moveFirst : Void
Move to the first page, has the same effect as clicking the 'first' button.
Move to the first page, has the same effect as clicking the 'first' button.
 
moveLast : Void
Move to the last page, has the same effect as clicking the 'last' button.
Move to the last page, has the same effect as clicking the 'last' button.
 
moveNext : Void
Move to the next page, has the same effect as clicking the 'next' button.
Move to the next page, has the same effect as clicking the 'next' button.
 
Move to the previous page, has the same effect as clicking the 'previous' button.
Move to the previous page, has the same effect as clicking the 'previous' button.
 
unbind( Ext.data.Store store ) : Void
Unbinds the paging toolbar from the specified Ext.data.Store (deprecated)
Unbinds the paging toolbar from the specified Ext.data.Store (deprecated)

Parameters

  • store : Ext.data.Store
    The data store to unbind

Returns

  • Void

Events

 
beforechange( Ext.toolbar.PagingToolbar this, Object params )
Fires just before the active page is changed. Return false to prevent the active page from being changed.
Fires just before the active page is changed. Return false to prevent the active page from being changed.

Parameters

  • this : Ext.toolbar.PagingToolbar
  • params : Object
    An object hash of the parameters which the PagingToolbar will send when loading the required page. This will contain:
    • start : Number
      The starting row number for the next page of records to be retrieved from the server
    • limit : Number
      The number of records to be retrieved from the server

    (note: the names of the start and limit properties are determined by the store's paramNames property.)

    Parameters may be added as required in the event handler.

Returns

  • Void
 
change( Ext.toolbar.PagingToolbar this, Object pageData )
Fires after the active page has been changed.
Fires after the active page has been changed.

Parameters

  • this : Ext.toolbar.PagingToolbar
  • pageData : Object
    An object that has these properties:
    • total : Number
      The total number of records in the dataset as returned by the server
    • activePage : Number
      The current page number
    • pages : Number
      The total number of pages (calculated from the total number of records in the dataset as returned by the server and the current pageSize)

Returns

  • Void
 
overflowchange( Object c, Boolean lastOverflow )
Fires after the overflow state has changed.
Fires after the overflow state has changed.

Parameters

  • c : Object
    The Container
  • lastOverflow : Boolean
    overflow state

Returns

  • Void