1 Ext.Loader.setConfig({enabled: true});
3 Ext.Loader.setPath('Ext.ux', '../ux/');
8 'Ext.grid.PagingScroller'
11 Ext.onReady(function(){
13 * Returns an array of fake data
14 * @param {Number} count The number of fake rows to create data for
15 * @return {Array} The fake record data, suitable for usage with an ArrayReader
17 function createFakeData(count) {
18 var firstNames = ['Ed', 'Tommy', 'Aaron', 'Abe', 'Jamie', 'Adam', 'Dave', 'David', 'Jay', 'Nicolas', 'Nige'],
19 lastNames = ['Spencer', 'Maintz', 'Conran', 'Elias', 'Avins', 'Mishcon', 'Kaneda', 'Davis', 'Robinson', 'Ferrero', 'White'],
20 ratings = [1, 2, 3, 4, 5],
21 salaries = [100, 400, 900, 1500, 1000000];
24 for (var i = 0; i < (count || 25); i++) {
25 var ratingId = Math.floor(Math.random() * ratings.length),
26 salaryId = Math.floor(Math.random() * salaries.length),
27 firstNameId = Math.floor(Math.random() * firstNames.length),
28 lastNameId = Math.floor(Math.random() * lastNames.length),
30 rating = ratings[ratingId],
31 salary = salaries[salaryId],
32 name = Ext.String.format("{0} {1}", firstNames[firstNameId], lastNames[lastNameId]);
43 Ext.define('Employee', {
44 extend: 'Ext.data.Model',
46 {name: 'rating', type: 'int'},
47 {name: 'salary', type: 'float'},
53 // create the Data Store
54 var store = Ext.create('Ext.data.Store', {
57 // allow the grid to interact with the paging scroller by buffering
59 // never purge any data, we prefetch all up front
69 var grid = Ext.create('Ext.grid.Panel', {
72 title: 'Bufffered Grid of 5,000 random records',
75 xtype: 'paginggridscroller',
79 disableSelection: true,
80 invalidateScrollerOnRefresh: false,
105 renderer: Ext.util.Format.usMoney
107 renderTo: Ext.getBody()
110 var data = createFakeData(5000),
114 for (; i < ln; i++) {
115 records.push(Ext.ModelManager.create(data[i], 'Employee'));
117 store.cacheRecords(records);
119 store.guaranteeRange(0, 49);