3 This file is part of Ext JS 4
5 Copyright (c) 2011 Sencha Inc
7 Contact: http://www.sencha.com/contact
9 GNU General Public License Usage
10 This file may be used under the terms of the GNU General Public License version 3.0 as published by the Free Software Foundation and appearing in the file LICENSE included in the packaging of this file. Please review the following information to ensure the GNU General Public License version 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html.
12 If you are unsure which license is appropriate for your use, please contact the sales department at http://www.sencha.com/contact.
15 Ext.Loader.setConfig({enabled: true});
17 Ext.Loader.setPath('Ext.ux', '../ux/');
22 'Ext.grid.PagingScroller'
25 Ext.define('Employee', {
26 extend: 'Ext.data.Model',
28 {name: 'rating', type: 'int'},
29 {name: 'salary', type: 'float'},
34 Ext.onReady(function(){
36 * Returns an array of fake data
37 * @param {Number} count The number of fake rows to create data for
38 * @return {Array} The fake record data, suitable for usage with an ArrayReader
40 function createFakeData(count) {
41 var firstNames = ['Ed', 'Tommy', 'Aaron', 'Abe', 'Jamie', 'Adam', 'Dave', 'David', 'Jay', 'Nicolas', 'Nige'],
42 lastNames = ['Spencer', 'Maintz', 'Conran', 'Elias', 'Avins', 'Mishcon', 'Kaneda', 'Davis', 'Robinson', 'Ferrero', 'White'],
43 ratings = [1, 2, 3, 4, 5],
44 salaries = [100, 400, 900, 1500, 1000000];
47 for (var i = 0; i < (count || 25); i++) {
48 var ratingId = Math.floor(Math.random() * ratings.length),
49 salaryId = Math.floor(Math.random() * salaries.length),
50 firstNameId = Math.floor(Math.random() * firstNames.length),
51 lastNameId = Math.floor(Math.random() * lastNames.length),
53 rating = ratings[ratingId],
54 salary = salaries[salaryId],
55 name = Ext.String.format("{0} {1}", firstNames[firstNameId], lastNames[lastNameId]);
65 // create the Data Store
66 var store = Ext.create('Ext.data.Store', {
69 // allow the grid to interact with the paging scroller by buffering
71 // never purge any data, we prefetch all up front
81 var grid = Ext.create('Ext.grid.Panel', {
84 title: 'Bufffered Grid of 5,000 random records',
87 xtype: 'paginggridscroller',
91 disableSelection: true,
92 invalidateScrollerOnRefresh: false,
117 renderer: Ext.util.Format.usMoney
119 renderTo: Ext.getBody()
122 var data = createFakeData(5000),
126 for (; i < ln; i++) {
127 records.push(Ext.create('Employee', data[i]));
129 store.cacheRecords(records);
131 store.guaranteeRange(0, 49);