Package: | Ext |
Defined In: | IndexBar.js |
Class: | IndexBar |
Extends: | Object |
IndexBar is a component used to display a list of data (primarily an alphabet) which can then be used to quickly navigate through a list (see Ext.List) of data. When a user taps on an item in the Ext.IndexBar, it will fire the index event.
Here is an example of the usage in a Ext.List:
Ext.regModel('Contact', {
fields: ['firstName', 'lastName']
});
var store = new Ext.data.JsonStore({
model : 'Contact',
sorters: 'lastName',
getGroupString : function(record) {
return record.get('lastName')[0];
},
data: [
{firstName: 'Tommy', lastName: 'Maintz'},
{firstName: 'Rob', lastName: 'Dougan'},
{firstName: 'Ed', lastName: 'Spencer'},
{firstName: 'Jamie', lastName: 'Avins'},
{firstName: 'Aaron', lastName: 'Conran'},
{firstName: 'Dave', lastName: 'Kaneda'},
{firstName: 'Michael', lastName: 'Mullany'},
{firstName: 'Abraham', lastName: 'Elias'},
{firstName: 'Jay', lastName: 'Robinson'},
{firstName: 'Tommy', lastName: 'Maintz'},
{firstName: 'Rob', lastName: 'Dougan'},
{firstName: 'Ed', lastName: 'Spencer'},
{firstName: 'Jamie', lastName: 'Avins'},
{firstName: 'Aaron', lastName: 'Conran'},
{firstName: 'Dave', lastName: 'Kaneda'},
{firstName: 'Michael', lastName: 'Mullany'},
{firstName: 'Abraham', lastName: 'Elias'},
{firstName: 'Jay', lastName: 'Robinson'}
]
});
var list = new Ext.List({
tpl: '<tpl for="."><div class="contact">{firstName} <strong>{lastName}</strong></div></tpl>',
itemSelector: 'div.contact',
singleSelect: true,
grouped : true,
indexBar : true,
store: store,
floating : true,
width : 350,
height : 370,
centered : true,
modal : true,
hideOnMaskTap: false
});
list.show();
Alternatively you can initate the Ext.IndexBar component manually in a custom component by using something similar to the following example:
var indexBar = new Ext.IndexBar({
dock : 'right',
overlay : true,
alphabet: true
});
Config Options | Defined By | |
---|---|---|
alphabet : Boolean | IndexBar | |
componentCls : String Base CSS class
Defaults to 'x-indexbar' | IndexBar | |
direction : String Layout direction, can be either 'vertical' or 'horizontal'
Defaults to 'vertical' | IndexBar | |
itemSelector : String Required. A simple CSS selector (e.g. div.x-indexbar-item for items | IndexBar | |
letters : Array The letters to show on the index bar. Defaults to the English alphabet, A-Z. | IndexBar | |
listPrefix : String The prefix string to be appended at the beginning of the list. E.g: useful to add a "#" prefix before numbers | IndexBar | |
store : Ext.data.Store The store to be used for displaying data on the index bar. The store model must have a value field when using the
def... | IndexBar | |
tpl : String Template for items | IndexBar |
Method | Defined By | |
---|---|---|
IndexBar( Object config )
Create a new IndexBar Create a new IndexBar Parameters:
| IndexBar | |
isHorizontal()
:
Boolean Method to determine whether this Sortable is currently sorting. Method to determine whether this Sortable is currently sorting. Parameters:
| IndexBar | |
isVertical()
:
Boolean Method to determine whether this Sortable is currently disabled. Method to determine whether this Sortable is currently disabled. Parameters:
| IndexBar | |
refresh()
:
void Refreshes the view by reloading the data from the store and re-rendering the template. Refreshes the view by reloading the data from the store and re-rendering the template. Parameters:
| IndexBar |
Event | Defined By | |
---|---|---|
index :
( Ext.data.Model record , HTMLElement target , Number index )
Fires when an item in the index bar display has been tapped Fires when an item in the index bar display has been tapped Listeners will be called with the following arguments:
| IndexBar |