4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5 <title>The source code</title>
6 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
7 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
8 <style type="text/css">
9 .highlight { display: block; background-color: #ddd; }
11 <script type="text/javascript">
12 function highlight() {
13 document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
17 <body onload="prettyPrint(); highlight();">
18 <pre class="prettyprint lang-js"><span id='Ext-grid-feature-Chunking'>/**
19 </span> * @class Ext.grid.feature.Chunking
20 * @extends Ext.grid.feature.Feature
22 Ext.define('Ext.grid.feature.Chunking', {
23 extend: 'Ext.grid.feature.Feature',
24 alias: 'feature.chunking',
27 rowHeight: Ext.isIE ? 27 : 26,
29 hasFeatureEvent: false,
30 attachEvents: function() {
31 var grid = this.view.up('gridpanel'),
32 scroller = grid.down('gridscroller[dock=right]');
33 scroller.el.on('scroll', this.onBodyScroll, this, {buffer: 300});
34 //this.view.on('bodyscroll', this.onBodyScroll, this, {buffer: 300});
37 onBodyScroll: function(e, t) {
40 nextChunk = Math.floor(top / this.rowHeight / this.chunkSize);
41 if (nextChunk !== this.visibleChunk) {
43 this.visibleChunk = nextChunk;
45 view.el.dom.scrollTop = top;
46 //BrowserBug: IE6,7,8 quirks mode takes setting scrollTop 2x.
47 view.el.dom.scrollTop = top;
51 collectData: function(records, preppedRecords, startIndex, fullWidth, orig) {
53 fullWidth: orig.fullWidth,
56 //headerCt = this.view.headerCt,
57 //colums = headerCt.getColumnsForTpl(),
58 recordCount = orig.rows.length,
61 visibleChunk = this.visibleChunk,
66 for (; start < recordCount; start+=this.chunkSize, i++) {
67 if (start+this.chunkSize > recordCount) {
68 chunkLength = recordCount - start;
70 chunkLength = this.chunkSize;
73 if (i >= visibleChunk - 1 && i <= visibleChunk + 1) {
74 rows = orig.rows.slice(start, start+this.chunkSize);
81 chunkHeight: chunkLength * this.rowHeight
89 getTableFragments: function() {
91 openTableWrap: function() {
92 return '<tpl for="chunks"><div class="' + Ext.baseCSSPrefix + 'grid-chunk" style="height: {chunkHeight}px;">';
94 closeTableWrap: function() {
95 return '</div></tpl>';