Changeset 17
- Timestamp:
- 08/30/08 18:54:41 (4 years ago)
- Location:
- trunk
- Files:
-
- 4 modified
-
CHANGELOG (modified) (1 diff)
-
src/BufferedGridView.js (modified) (15 diffs)
-
src/BufferedRowSelectionModel.js (modified) (4 diffs)
-
src/BufferedStore.js (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/CHANGELOG
r15 r17 1 Version 0.2rc 31 Version 0.2rc4 2 2 30-August-2008 3 3 4 - fixes; 4 - fixes: 5 - BufferedStore.js: store would not allow for adding records without throwing errors when 6 the store was initialized with no records; changed bufferRange to be initialized with [0,0] 7 instead of [0, bufferSize] and incremented bufferRange-count according to the records coming 8 in, until bufferRange[1] equals to bufferSize 9 - BufferedGridView.js, BufferedRowSelectionModel.js: store "add" event would neccessarily 10 trigger the selectionmodel's onAdd-listener before the onAdd-listener of the GridView, resulting 11 in false rendering of selected records; changed the selection model to listen to the "rowsinserted" 12 event of the view and extended this event to pass the length of added record as the fourth 13 parameter to all it's listeners 14 - BufferedGridView.js: collapsed panel would hide added records of the grid when the grid is 15 expanded again and would lose scroll-position; added listener for "expand"-event of the view's 16 gridpanel to recalculate visible rows, the buffer inset and reset the scrollbar's position to the 17 proper value 18 - BufferedGridView.js: "onAdd()" would not always insert records depending on the position they got 19 added in the store; updated and improved code based on "rows get added before first visible row", 20 "rows get added after the last visible row", "rows get added somewhere in between the first and last visible row" 21 - enhancements: 22 - BufferedGridView.js: improved calculation of rows that would cause spill when new records 23 get added in "insertRows()" 24 25 26 Version 0.2rc3 27 30-August-2008 28 29 - fixes: 5 30 - BufferedGridView.js: last row would not always be rendered proper if the end of 6 31 records is reached and the panel would be resized so that more records are displayable -
trunk/src/BufferedGridView.js
r15 r17 337 337 Ext.ux.grid.BufferedGridView.superclass.init.call(this, grid); 338 338 339 grid.on('expand', this._onExpand, this); 340 339 341 this.ds.on('beforeload', this.onBeforeLoad, this); 340 342 }, … … 463 465 // {{{ ----------------------dom/mouse listeners-------------------------------- 464 466 467 /** 468 * Tells the view to recalculate the number of rows displayable 469 * and the buffer inset, when it gets expanded after it has been 470 * collapsed. 471 * 472 */ 473 _onExpand : function(panel) 474 { 475 this.adjustVisibleRows(); 476 this.adjustBufferInset(); 477 this.adjustScrollerPos(this.rowHeight*this.rowIndex, true); 478 }, 479 465 480 // private 466 481 onColumnMove : function(cm, oldIndex, newIndex) … … 766 781 this.adjustScrollerPos(this.rowHeight*recordLen, true); 767 782 768 this.fireEvent("rowsinserted", this, index, index );783 this.fireEvent("rowsinserted", this, index, index, recordLen); 769 784 this.processRows(); 770 785 // the cursor did virtually move … … 777 792 778 793 this.adjustBufferInset(); 779 this.fireEvent("rowsinserted", this, index, index );794 this.fireEvent("rowsinserted", this, index, index, recordLen); 780 795 return; 781 796 } … … 790 805 791 806 // rows would be added at the end of the rows which are currently 792 // displayed, so fire the evnt and return 793 if (index >= (this.rowIndex-this.ds.bufferRange[0])+len && len == this.visibleRows) { 807 // displayed, so fire the event, resize buffer and adjust visible 808 // rows and return 809 if (start > this.rowIndex+(this.visibleRows-1)) { 794 810 this.fireEvent("beforerowsinserted", this, start, end); 795 this.fireEvent("rowsinserted", this, start, end);811 this.fireEvent("rowsinserted", this, start, end, recordLen); 796 812 797 813 this.adjustVisibleRows(); … … 800 816 } 801 817 802 // we are all up in the grid, first row is first record, 803 // prepend! 804 else if (index == 0 && this.rowIndex == 0) { 818 // rows get added somewhere in the current view. 819 else if (start >= this.rowIndex && start <= this.rowIndex+(this.visibleRows-1)) { 805 820 firstRow = index; 806 lastRow = Math.min(end, this.rowIndex+this.visibleRows-1) - this.ds.bufferRange[0]; 821 // compute the last row that would be affected of an insert operation 822 lastRow = index+(recordLen-1); 807 823 this.lastRowIndex = this.rowIndex; 808 this.rowIndex = 0; 824 this.rowIndex = (start > this.rowIndex) ? this.rowIndex : start; 825 809 826 this.insertRows(ds, firstRow, lastRow); 827 828 if (this.lastRowIndex != this.rowIndex) { 829 this.fireEvent('cursormove', this, this.rowIndex, 830 Math.min(this.ds.totalLength, this.visibleRows-this.rowClipped), 831 this.ds.totalLength); 832 } 810 833 811 834 this.adjustVisibleRows(); … … 813 836 } 814 837 815 // rows get added before the first row in the view816 else if (len == this.visibleRows && index <= this.rowIndex-this.ds.bufferRange[0]) {817 838 // rows get added before the first visible row, which would not affect any 839 // rows to be re-rendered 840 else if (start < this.rowIndex) { 818 841 this.fireEvent("beforerowsinserted", this, start, end); 819 this.liveScroller.un('scroll', this.onLiveScroll, this); 842 820 843 this.rowIndex = this.rowIndex+recordLen; 821 844 this.lastRowIndex = this.rowIndex; … … 826 849 this.adjustScrollerPos(this.rowHeight*recordLen, true); 827 850 828 this.fireEvent("rowsinserted", this, start, end); 829 this.processRows(); 851 this.fireEvent("rowsinserted", this, start, end, recordLen); 852 this.processRows(0, undefined, true); 853 830 854 this.fireEvent('cursormove', this, this.rowIndex, 831 855 Math.min(this.ds.totalLength, this.visibleRows-this.rowClipped), 832 856 this.ds.totalLength); 833 }834 835 // rows get added somewhere IN the current view836 else if ((len < this.visibleRows ) || index > this.rowIndex-this.ds.bufferRange[0]) {837 firstRow = index;838 lastRow = Math.min(end, this.rowIndex+this.visibleRows-1) - this.ds.bufferRange[0];839 this.insertRows(ds, firstRow, lastRow);840 841 this.adjustVisibleRows();842 this.adjustBufferInset();843 844 857 } 845 858 … … 1053 1066 var selections = this.grid.selModel.selections; 1054 1067 var ds = this.ds; 1068 var row = null; 1055 1069 for(var i = startRow, len = rows.length; i < len; i++){ 1056 index = i+cursor;1057 var row= rows[i];1070 index = i+cursor; 1071 row = rows[i]; 1058 1072 // changed! 1059 1073 row.rowIndex = index; … … 1062 1076 if (this.grid.selModel.bufferedSelections[index] === true) { 1063 1077 this.addRowClass(i, "x-grid3-row-selected"); 1078 } else { 1079 this.removeRowClass(i, "x-grid3-row-selected"); 1064 1080 } 1065 1081 this.fly(row).removeClass("x-grid3-row-over"); … … 1099 1115 // first off, remove the rows at the bottom of the view to match the 1100 1116 // visibleRows value and to not cause any spill in the DOM 1101 if (isUpdate !== true && this.getRows().length == this.visibleRows) {1117 if (isUpdate !== true && (this.getRows().length + (lastRow-firstRow)) >= this.visibleRows) { 1102 1118 this.removeRows((this.visibleRows-1)-(lastRow-firstRow), this.visibleRows-1); 1103 } 1104 1105 if (isUpdate) { 1119 } else if (isUpdate) { 1106 1120 this.removeRows(viewIndexFirst-this.rowIndex, viewIndexLast-this.rowIndex); 1107 1121 } 1108 1122 1109 var html = this.renderRows(firstRow, lastRow); 1123 // compute the range of possible records which could be drawn into the view without 1124 // causing any spill 1125 var lastRenderRow = (firstRow == lastRow) 1126 ? lastRow 1127 : Math.min(lastRow, (this.rowIndex-this.ds.bufferRange[0])+(this.visibleRows-1)); 1128 1129 var html = this.renderRows(firstRow, lastRenderRow); 1110 1130 1111 1131 var before = this.getRow(firstRow-(this.rowIndex-this.ds.bufferRange[0])); … … 1119 1139 1120 1140 1121 if ( isUpdate === true) {1141 if (!isUpdate === true) { 1122 1142 var rows = this.getRows(); 1123 1143 var cursor = this.rowIndex; … … 1128 1148 1129 1149 if (!isUpdate) { 1130 this.fireEvent("rowsinserted", this, viewIndexFirst, viewIndexLast );1131 this.processRows( );1150 this.fireEvent("rowsinserted", this, viewIndexFirst, viewIndexLast, (viewIndexLast-viewIndexFirst)+1); 1151 this.processRows(0, undefined, true); 1132 1152 } 1133 1153 }, … … 1521 1541 if (this.getRows()[0]) { 1522 1542 this.rowHeight = this.getRows()[0].offsetHeight; 1543 1544 if (this.rowHeight <= 0) { 1545 this.rowHeight = -1; 1546 return; 1547 } 1548 1523 1549 } else { 1524 1550 return; … … 1565 1591 return; 1566 1592 } 1593 1567 1594 // when re-rendering, doe not take the clipped row into account 1568 1595 if (this.rowIndex + (visibleRows-this.rowClipped) > totalLength) { -
trunk/src/BufferedRowSelectionModel.js
r11 r17 45 45 Ext.ux.grid.BufferedRowSelectionModel.superclass.initEvents.call(this); 46 46 47 this.grid. store.on('add',this.onAdd, this);47 this.grid.view.on('rowsinserted', this.onAdd, this); 48 48 this.grid.store.on('selectionsload', this.onSelectionsLoad, this); 49 49 }, … … 129 129 130 130 /** 131 * If records where added to the store, this method will work as a callback. 132 * The method gets usually called <b>after</b> the onAdd method of the according 133 * view was called. 131 * If records where added to the store, this method will work as a callback, 132 * called by the views' rowsinserted event. 134 133 * Selections will be shifted down if, and only if, the listeners for the 135 134 * selectiondirty event will return <tt>true</tt>. 136 135 * 137 136 */ 138 onAdd : function(store, records, index)137 onAdd : function(store, index, endIndex, recordLength) 139 138 { 140 139 var ranges = this.getPendingSelections(); … … 148 147 // in the current buffer range will be shifted up! 149 148 if (rangesLength == 0 && index == Number.MIN_VALUE) { 150 this.shiftSelections(this.grid.getStore().bufferRange[0], record s.length);151 } 152 153 this.fireEvent('selectiondirty', this, index, record s.length);149 this.shiftSelections(this.grid.getStore().bufferRange[0], recordLength); 150 } 151 152 this.fireEvent('selectiondirty', this, index, recordLength); 154 153 return; 155 154 } 156 155 157 156 if (rangesLength == 0) { 158 this.shiftSelections( this.grid.getStore().bufferRange[0]+index, records.length);157 this.shiftSelections(index, recordLength); 159 158 return; 160 159 } … … 165 164 var s = ranges[0]; 166 165 var e = ranges[rangesLength-1]; 167 var viewIndex = this.grid.getStore().bufferRange[0]+index;166 var viewIndex = index; 168 167 if (viewIndex <= e || viewIndex <= s) { 169 if (this.fireEvent('selectiondirty', this, viewIndex, record s.length) !== false) {170 this.shiftSelections(viewIndex, record s.length);168 if (this.fireEvent('selectiondirty', this, viewIndex, recordLength) !== false) { 169 this.shiftSelections(viewIndex, recordLength); 171 170 } 172 171 } -
trunk/src/BufferedStore.js
r11 r17 124 124 * @param {Array} 125 125 */ 126 this.bufferRange = [0, this.bufferSize];126 this.bufferRange = [0, 0]; 127 127 128 128 this.on('clear', function (){ 129 this.bufferRange = [0, this.bufferSize];129 this.bufferRange = [0, 0]; 130 130 }, this); 131 131 … … 191 191 } 192 192 this.totalLength += insertRecords.length; 193 194 // if the store was loaded without data and the bufferRange 195 // has to be filled first 196 if (this.bufferRange[1] < this.bufferSize) { 197 this.bufferRange[1] = Math.min(this.bufferRange[1] + insertRecords.length, this.bufferSize); 198 } 193 199 194 200 for (var i = 0, len = insertRecords.length; i < len; i++) {
