Changeset 31

Show
Ignore:
Timestamp:
11/01/08 20:39:14 (4 years ago)
Author:
tsuckowhomberg
google:author:
tsuckowhomberg
Message:
  • enhancement: (Toolbar.js) config object allows now to specify either the grid or the view the toolbar is bound to
  • fixed: (Store.js) "getAt()" would return "-1" if the data at the passed index could not be found in some cases; changed to return type "undefined"
  • fixed: (GridView?.js) overrode method "getCell()" to return "null" if the row for the specified index could not be found
  • fixed: firing of event "cursormove" would happen before "replaceLiveRows()" has taken care of re-assigning the rowIndex to the rows in the view which could lead to errors; adjusted method and made sure that "replaceLiveRows()" is called first
  • enhancement: (EditorGridPanel?.js, GridPanel?.js) added basic support for using cell editors for the Livegrid (EditorGridPanel?-support)
  • enhancement: (ext-ux-livegrid.css, DragZone?.js) minor code cleanups, changed css class "x-dd-drop-waiting" to "ext-ux-livegrid-drop-waiting"
  • enhancement: (GridView?.js) added method "getRow()", removed overriden method "onCellSelect()", "onCellDeselect()", "onRowOver()", "onRowOut()" and changed arguments for call of methods that operate on Html-elements in the view to pass the model index as specified in the elements "rowIndex"-property, which will get translated internally to the html-element's index in the view, for broadening

compatibility to other plugins/exension, such as the EditorGridPanel?

  • enhancement: (GridView?.js) changed behavior of "processRows()" to paint the selections if the third argument does not equal to "false"
  • enhancement: (RowSelectionModel?.js) added method "deselectRecord()" to deselect a record that is already selected in the model
  • enhancement: (GridView?.js) added method "isRecordRendered()" to check whether the passed record is currently within the visible rect of the grid's view
Location:
trunk
Files:
2 added
9 modified

Legend:

Unmodified
Added
Removed
  • trunk/CHANGELOG

    r30 r31  
    1  - enhancement: removed programmatically invoking scroll in IE when the grid is rendered, 
     1Version 0.3a2 (GPL) 
     21-November-2008 
     3 
     4 - enhancement: (Toolbar.js) config object allows now to specify either the grid 
     5or the view the toolbar is bound to 
     6 - fixed: (Store.js) "getAt()" would return "-1" if the data at the passed index 
     7could not be found in some cases; changed to return type "undefined" 
     8 - fixed: (GridView.js) overrode method "getCell()" to return "null" if the row 
     9for the specified index could not be found 
     10 - fixed: firing of event "cursormove" would happen before "replaceLiveRows()" 
     11has taken care of re-assigning the rowIndex to the rows in the view which could 
     12lead to errors; adjusted method and made sure that "replaceLiveRows()" is called 
     13first 
     14 - enhancement: (EditorGridPanel.js, GridPanel.js) added basic support for using 
     15cell editors for the Livegrid (EditorGridPanel-support) 
     16 - enhancement: (ext-ux-livegrid.css, DragZone.js) minor code cleanups, changed 
     17css class "x-dd-drop-waiting" to "ext-ux-livegrid-drop-waiting" 
     18 - enhancement: (GridView.js) added method "getRow()", removed overriden method 
     19"onCellSelect()", "onCellDeselect()", "onRowOver()", "onRowOut()" and changed 
     20arguments for call of methods that operate on Html-elements in the view to pass 
     21the model index as specified in the elements "rowIndex"-property, which will get 
     22translated internally to the html-element's index in the view, for broadening 
     23compatibility to other plugins/exension, such as the EditorGridPanel 
     24 - enhancement: (GridView.js) changed behavior of "processRows()" to paint the selections 
     25if the third argument does not equal to "false" 
     26 - enhancement: (RowSelectionModel.js) added method "deselectRecord()" to deselect a record 
     27that is already selected in the model 
     28 - enhancement: (GridView.js) added method "isRecordRendered()" to check whether the passed 
     29record is currently within the visible rect of the grid's view 
     30 - enhancement: removed programmatically invoking scroll in IE when the grid is rendered, 
    231since this was fixed due to the css changes in a previously version 
    332 - fixed: (RowSelectionModel.js) method "isSelected()" would lose it's original argument 
  • trunk/README

    r2 r31  
    66------------- 
    77http://www.siteartwork.de/livegrid 
     8 
     9History: 
     10-------- 
     11Ext.ux.Livegrid is a subproject of ongoo. Visit <http://www.ongoo.org> for 
     12more informations. 
  • trunk/src/DragZone.js

    r26 r31  
    77 * license. 
    88 * 
    9  * Commercial use is prohibited. Contact "Thorsten Suckow-Homberg" <ts@siteartwork.de> 
    10  * if you need a commercial license. 
     9 * Commercial use is prohibited. Visit <http://www.siteartwork.de/livegrid> 
     10 * if you need to obtain a commercial license. 
    1111 * 
    1212 * This program is free software: you can redistribute it and/or modify it under 
     
    2222 * this program. If not, see <http://www.gnu.org/licenses/gpl.html>. 
    2323 * 
    24  * If you would like to support the development and support of the Ext.ux.Livegrid 
    25  * component, you can make a donation: <http://www.siteartwork.de/livegrid> 
    2624 */ 
    2725 
     
    3533Ext.ux.grid.livegrid.DragZone = function(grid, config){ 
    3634 
    37     this.view = grid.getView(); 
    38     Ext.ux.grid.livegrid.DragZone.superclass.constructor.call(this, this.view.mainBody.dom, config); 
     35    Ext.ux.grid.livegrid.DragZone.superclass.constructor.call(this, grid, config); 
    3936 
    40     if(this.view.lockedBody){ 
    41         this.setHandleElId(Ext.id(this.view.mainBody.dom)); 
    42         this.setOuterHandleElId(Ext.id(this.view.lockedBody.dom)); 
    43     } 
    44  
    45     this.scroll = false; 
    46     this.grid   = grid; 
    47     this.ddel   = document.createElement('div'); 
    48  
    49     this.ddel.className = 'x-grid-dd-wrap'; 
    50  
    51     this.view.ds.on('beforeselectionsload', this.onBeforeSelectionsLoad, this); 
    52     this.view.ds.on('selectionsload',       this.onSelectionsLoad,       this); 
     37    this.view.ds.on('beforeselectionsload', this._onBeforeSelectionsLoad, this); 
     38    this.view.ds.on('selectionsload',       this._onSelectionsLoad,       this); 
    5339}; 
    5440 
    55 Ext.extend(Ext.ux.grid.livegrid.DragZone, Ext.dd.DragZone, { 
    56     ddGroup : "GridDD", 
     41Ext.extend(Ext.ux.grid.livegrid.DragZone, Ext.grid.GridDragZone, { 
    5742 
     43    /** 
     44     * Tells whether a drop is valid. Used inetrnally to determine if pending 
     45     * selections need to be loaded/ have been loaded. 
     46     * @type {Boolean} 
     47     */ 
    5848    isDropValid : true, 
    5949 
    60     getDragData : function(e) 
    61     { 
    62         var t = Ext.lib.Event.getTarget(e); 
    63         var rowIndex = this.view.findRowIndex(t); 
    64         if(rowIndex !== false){ 
    65             var sm = this.grid.selModel; 
    66             if(!sm.isSelected(rowIndex) || e.hasModifier()){ 
    67                 sm.handleMouseDown(this.grid, rowIndex, e); 
    68             } 
    69  
    70             return {grid: this.grid, ddel: this.ddel, rowIndex: rowIndex, selections:sm.getSelections()}; 
    71         } 
    72         return false; 
    73     }, 
    74  
     50    /** 
     51     * Overriden for loading pending selections if needed. 
     52     */ 
    7553    onInitDrag : function(e) 
    7654    { 
    7755        this.view.ds.loadSelections(this.grid.selModel.getPendingSelections(true)); 
    7856 
    79         var data = this.dragData; 
    80         this.ddel.innerHTML = this.grid.getDragDropText(); 
    81         this.proxy.update(this.ddel); 
     57        Ext.ux.grid.livegrid.DragZone.superclass.onInitDrag.call(this, e); 
    8258    }, 
    8359 
    84     onBeforeSelectionsLoad : function() 
     60    /** 
     61     * Gets called before pending selections are loaded. Any drop 
     62     * operations are invalid/get paused if the component needs to 
     63     * wait for selections to load from the server. 
     64     * 
     65     */ 
     66    _onBeforeSelectionsLoad : function() 
    8567    { 
    8668        this.isDropValid = false; 
    87         Ext.fly(this.proxy.el.dom.firstChild).addClass('x-dd-drop-waiting'); 
     69        Ext.fly(this.proxy.el.dom.firstChild).addClass('ext-ux-livegrid-drop-waiting'); 
    8870    }, 
    8971 
    90     onSelectionsLoad : function() 
     72    /** 
     73     * Gets called after pending selections have been loaded. 
     74     * Any paused drop operation will be resumed. 
     75     * 
     76     */ 
     77    _onSelectionsLoad : function() 
    9178    { 
    9279        this.isDropValid = true; 
    9380        this.ddel.innerHTML = this.grid.getDragDropText(); 
    94         Ext.fly(this.proxy.el.dom.firstChild).removeClass('x-dd-drop-waiting'); 
    95     }, 
    96  
    97     afterRepair : function() 
    98     { 
    99         this.dragging = false; 
    100     }, 
    101  
    102     getRepairXY : function(e, data) 
    103     { 
    104         return false; 
    105     }, 
    106  
    107     onStartDrag : function() 
    108     { 
    109  
    110     }, 
    111  
    112     onEndDrag : function(data, e) 
    113     { 
    114     }, 
    115  
    116     onValidDrop : function(dd, e, id) 
    117     { 
    118         this.hideProxy(); 
    119     }, 
    120  
    121     beforeInvalidDrop : function(e, id) 
    122     { 
    123  
     81        Ext.fly(this.proxy.el.dom.firstChild).removeClass('ext-ux-livegrid-drop-waiting'); 
    12482    } 
    12583}); 
  • trunk/src/GridView.js

    r30 r31  
    77 * license. 
    88 * 
    9  * Commercial use is prohibited. Contact "Thorsten Suckow-Homberg" <ts@siteartwork.de> 
    10  * if you need a commercial license. 
     9 * Commercial use is prohibited. Visit <http://www.siteartwork.de/livegrid> 
     10 * if you need to obtain a commercial license. 
    1111 * 
    1212 * This program is free software: you can redistribute it and/or modify it under 
     
    2222 * this program. If not, see <http://www.gnu.org/licenses/gpl.html>. 
    2323 * 
    24  * If you would like to support the development and support of the Ext.ux.Livegrid 
    25  * component, you can make a donation: <http://www.siteartwork.de/livegrid> 
    2624 */ 
    2725 
     
    505503    /** 
    506504     * Overriden for Ext 2.2 to prevent call to focus Row. 
    507      * This method i s here for dom operations only - the passed argument is the 
    508      * index of the node in the dom, not in the model. 
    509505     * 
    510506     */ 
     
    578574    /** 
    579575     * Callback for selecting a row. The index of the row is the absolute index 
    580      * in the datamodel and gets translated to the index in the view. 
    581      * Overwrites the parent's implementation. 
     576     * in the datamodel. If the row is not rendered, this method will do nothing. 
    582577     */ 
    583578    // private 
     
    588583        } 
    589584 
    590         var viewIndex = row-this.rowIndex; 
    591  
    592         this.addRowClass(viewIndex, "x-grid3-row-selected"); 
     585        this.addRowClass(row, "x-grid3-row-selected"); 
    593586    }, 
    594587 
    595588    /** 
    596589     * Callback for deselecting a row. The index of the row is the absolute index 
    597      * in the datamodel and gets translated to the index in the view. 
    598      * Overwrites the parent's implementation. 
     590     * in the datamodel. If the row is not currently rendered in the view, this method 
     591     * will do nothing. 
    599592     */ 
    600593    // private 
     
    605598        } 
    606599 
    607         var viewIndex = row-this.rowIndex; 
    608  
    609         this.removeRowClass(viewIndex, "x-grid3-row-selected"); 
    610     }, 
    611  
    612     /** 
    613      * Callback for selecting a cell. The index of the row is the absolute index 
    614      * in the datamodel and gets translated to the index in the view. 
    615      * Overwrites the parent's implementation. 
    616      */ 
    617     // private 
    618     onCellSelect : function(row, col) 
    619     { 
    620         if (row < this.rowIndex || row > this.rowIndex+this.visibleRows) { 
    621             return; 
    622         } 
    623  
    624         var viewIndex = row-this.rowIndex; 
    625  
    626         var cell = this.getCell(viewIndex, col); 
    627         if(cell){ 
    628             this.fly(cell).addClass("x-grid3-cell-selected"); 
    629         } 
    630     }, 
    631  
    632     /** 
    633      * Callback for deselecting a cell. The index of the row is the absolute index 
    634      * in the datamodel and gets translated to the index in the view. 
    635      * Overwrites the parent's implementation. 
    636      */ 
    637     // private 
    638     onCellDeselect : function(row, col) 
    639     { 
    640         if (row < this.rowIndex || row > this.rowIndex+this.visibleRows) { 
    641             return; 
    642         } 
    643  
    644         var viewIndex = row-this.rowIndex; 
    645  
    646         var cell = this.getCell(viewIndex, col); 
    647         if(cell){ 
    648             this.fly(cell).removeClass("x-grid3-cell-selected"); 
    649         } 
    650     }, 
    651  
    652     /** 
    653      * Callback for onmouseover event of the grid's rows. The index of the row is 
    654      * the absolute index in the datamodel and gets translated to the index in the 
    655      * view. 
    656      * Overwrites the parent's implementation. 
    657      */ 
    658     // private 
    659     onRowOver : function(e, t) 
    660     { 
    661         var row; 
    662         if((row = this.findRowIndex(t)) !== false){ 
    663             var viewIndex = row-this.rowIndex; 
    664             this.addRowClass(viewIndex, "x-grid3-row-over"); 
    665         } 
    666     }, 
    667  
    668     /** 
    669      * Callback for onmouseout event of the grid's rows. The index of the row is 
    670      * the absolute index in the datamodel and gets translated to the index in the 
    671      * view. 
    672      * Overwrites the parent's implementation. 
    673      */ 
    674     // private 
    675     onRowOut : function(e, t) 
    676     { 
    677         var row; 
    678         if((row = this.findRowIndex(t)) !== false && row !== this.findRowIndex(e.getRelatedTarget())){ 
    679             var viewIndex = row-this.rowIndex; 
    680             this.removeRowClass(viewIndex, "x-grid3-row-over"); 
    681         } 
     600        this.removeRowClass(row, "x-grid3-row-selected"); 
    682601    }, 
    683602 
     
    818737 
    819738                this.fireEvent("rowsinserted", this, index, index, recordLen); 
    820                 this.processRows(); 
     739                this.processRows(0, undefined, false); 
    821740                // the cursor did virtually move 
    822741                this.fireEvent('cursormove', this, this.rowIndex, 
     
    1051970 
    1052971        var cursor = Math.floor((scrollTop)/this.rowHeight); 
     972 
    1053973        this.rowIndex = cursor; 
    1054974        // the lastRowIndex will be set when refreshing the view has finished 
     
    1058978 
    1059979        this.updateLiveRows(cursor); 
     980 
    1060981        this.lastScrollPos = this.liveScroller.dom.scrollTop; 
    1061982    }, 
     
    10841005 
    10851006        this.insertRows(ds, index, index, true); 
    1086         //this.getRow(index).rowIndex = index; 
    1087         //this.onRemove(ds, record, index+1, true); 
    10881007        this.fireEvent("rowupdated", this, viewIndex, record); 
    10891008    }, 
     
    11151034            row.rowIndex = index; 
    11161035 
    1117             if (paintSelections == true) { 
     1036            if (paintSelections !== false) { 
    11181037                if (this.grid.selModel.isSelected(this.ds.getAt(index)) === true) { 
    1119                     this.addRowClass(i, "x-grid3-row-selected"); 
     1038                    this.addRowClass(index, "x-grid3-row-selected"); 
    11201039                } else { 
    1121                     this.removeRowClass(i, "x-grid3-row-selected"); 
     1040                    this.removeRowClass(index, "x-grid3-row-selected"); 
    11221041                } 
    11231042                this.fly(row).removeClass("x-grid3-row-over"); 
     
    11711090        var html = this.renderRows(firstRow, lastRenderRow); 
    11721091 
    1173         var before = this.getRow(firstRow-(this.rowIndex-this.ds.bufferRange[0])); 
     1092        var before = this.getRow(viewIndexFirst); 
    11741093 
    11751094        if (before) { 
     
    11961115 
    11971116    /** 
     1117     * Return the <TR> HtmlElement which represents a Grid row for the specified index. 
     1118     * The passed argument is assumed to be the absolute index and will get translated 
     1119     * to the index of the row that represents the data in the view. 
     1120     * 
     1121     * @param {Number} index The row index 
     1122     * 
     1123     * @return {null|HtmlElement} The <TR> element, or null if the row is not rendered 
     1124     * in the view. 
     1125     */ 
     1126    getRow : function(row) 
     1127    { 
     1128        if (row-this.rowIndex < 0) { 
     1129            return null; 
     1130        } 
     1131 
     1132        return this.getRows()[row-this.rowIndex]; 
     1133    }, 
     1134 
     1135    /** 
     1136     * Returns the grid's <TD> HtmlElement at the specified coordinates. 
     1137     * Returns null if the specified row is not currently rendered. 
     1138     * 
     1139     * @param {Number} row The row index in which to find the cell. 
     1140     * @param {Number} col The column index of the cell. 
     1141     * @return {HtmlElement} The &lt;TD> at the specified coordinates. 
     1142     */ 
     1143    getCell : function(row, col) 
     1144    { 
     1145        var row = this.getRow(row); 
     1146 
     1147        return row 
     1148               ? row.getElementsByTagName('td')[col] 
     1149               : null; 
     1150    }, 
     1151 
     1152    /** 
    11981153     * Focuses the specified cell. 
    11991154     * @param {Number} row The row index 
     
    12441199            this.adjustScrollerPos((rowInd)*this.rowHeight); 
    12451200        } 
    1246         var rowInd = rowInd < 0 ? row : rowInd; 
    1247         var rowEl = this.getRow(rowInd), cellEl; 
     1201 
     1202        var rowEl = this.getRow(row), cellEl; 
    12481203 
    12491204        if(!(hscroll === false && col === 0)){ 
     
    12511206                col++; 
    12521207            } 
    1253             cellEl = this.getCell(row-this.rowIndex, col); 
     1208            cellEl = this.getCell(row, col); 
    12541209        } 
    12551210 
     
    12651220    }, 
    12661221 
     1222    /** 
     1223     * Return strue if the passed record is in the visible rect of this view. 
     1224     * 
     1225     * @param {Ext.data.Record} record 
     1226     * 
     1227     * @return {Boolean} true if the record is rendered in the view, otherwise false. 
     1228     */ 
     1229    isRecordRendered : function(record) 
     1230    { 
     1231        var ind = this.ds.indexOf(record); 
     1232 
     1233        if (ind >= this.rowIndex && ind < this.rowIndex+this.visibleRows) { 
     1234            return true; 
     1235        } 
     1236 
     1237        return false; 
     1238    }, 
    12671239 
    12681240    /** 
     
    13271299    updateLiveRows: function(index, forceRepaint, forceReload) 
    13281300    { 
    1329         this.fireEvent('cursormove', this, index, 
    1330                        Math.min(this.ds.totalLength, this.visibleRows-this.rowClipped), 
    1331                        this.ds.totalLength); 
    1332  
    13331301        var inRange = this.isInRange(index); 
    13341302 
    1335         if (this.isBuffering && this.isPrebuffering) { 
    1336             if (inRange) { 
    1337                 this.replaceLiveRows(index); 
    1338             } else { 
    1339                 this.showLoadMask(true); 
    1340             } 
    1341         } 
    13421303        if (this.isBuffering) { 
     1304            if (this.isPrebuffering) { 
     1305                if (inRange) { 
     1306                    this.replaceLiveRows(index); 
     1307                } else { 
     1308                    this.showLoadMask(true); 
     1309                } 
     1310            } 
     1311 
     1312            this.fireEvent('cursormove', this, index, 
     1313                           Math.min(this.ds.totalLength, 
     1314                           this.visibleRows-this.rowClipped), 
     1315                           this.ds.totalLength); 
     1316 
    13431317            this.requestQueue = index; 
    13441318            return; 
     
    13551329            // repaint the table's view 
    13561330            this.replaceLiveRows(index, forceRepaint); 
    1357  
     1331            // has to be called AFTER the rowIndex was recalculated 
     1332            this.fireEvent('cursormove', this, index, 
     1333                       Math.min(this.ds.totalLength, 
     1334                       this.visibleRows-this.rowClipped), 
     1335                       this.ds.totalLength); 
    13581336            // lets decide if we can void this method or stay in here for 
    13591337            // requesting a buffer update 
  • trunk/src/JsonReader.js

    r26 r31  
    77 * license. 
    88 * 
    9  * Commercial use is prohibited. Contact "Thorsten Suckow-Homberg" <ts@siteartwork.de> 
    10  * if you need a commercial license. 
     9 * Commercial use is prohibited. Visit <http://www.siteartwork.de/livegrid> 
     10 * if you need to obtain a commercial license. 
    1111 * 
    1212 * This program is free software: you can redistribute it and/or modify it under 
     
    2222 * this program. If not, see <http://www.gnu.org/licenses/gpl.html>. 
    2323 * 
    24  * If you would like to support the development and support of the Ext.ux.Livegrid 
    25  * component, you can make a donation: <http://www.siteartwork.de/livegrid> 
    2624 */ 
    2725 
  • trunk/src/resources/css/ext-ux-livegrid.css

    r26 r31  
    1 .x-dd-drop-waiting { 
     1.ext-ux-livegrid-drop-waiting { 
    22    background-image:url(../images/loading.gif) !important; 
    33} 
  • trunk/src/RowSelectionModel.js

    r29 r31  
    77 * license. 
    88 * 
    9  * Commercial use is prohibited. Contact "Thorsten Suckow-Homberg" <ts@siteartwork.de> 
    10  * if you need a commercial license. 
     9 * Commercial use is prohibited. Visit <http://www.siteartwork.de/livegrid> 
     10 * if you need to obtain a commercial license. 
    1111 * 
    1212 * This program is free software: you can redistribute it and/or modify it under 
     
    2222 * this program. If not, see <http://www.gnu.org/licenses/gpl.html>. 
    2323 * 
    24  * If you would like to support the development and support of the Ext.ux.Livegrid 
    25  * component, you can make a donation: <http://www.siteartwork.de/livegrid> 
    2624 */ 
    2725 
     
    316314 
    317315    /** 
     316     * Deselects a record. 
     317     * The emthod assumes that the record is physically available, i.e. 
     318     * pendingSelections will not be taken into account 
     319     */ 
     320    deselectRecord : function(record, preventViewNotify) 
     321    { 
     322        if(this.locked) { 
     323            return; 
     324        } 
     325 
     326        var isSelected = this.selections.key(record.id); 
     327 
     328        if (!isSelected) { 
     329            return; 
     330        } 
     331 
     332        var store = this.grid.store; 
     333        var index = store.indexOfId(record.id); 
     334 
     335        if (index == -1) { 
     336            index = store.findInsertIndex(record); 
     337            if (index != Number.MIN_VALUE && index != Number.MAX_VALUE) { 
     338                index += store.bufferRange[0]; 
     339            } 
     340        } else { 
     341            // just to make sure, though this should not be 
     342            // set if the record was availablein the selections 
     343            delete this.pendingSelections[index]; 
     344        } 
     345 
     346        if (this.last == index) { 
     347            this.last = false; 
     348        } 
     349 
     350        if (this.lastActive == index) { 
     351            this.lastActive = false; 
     352        } 
     353 
     354        this.selections.remove(record); 
     355 
     356        if(!preventViewNotify){ 
     357            this.grid.getView().onRowDeselect(index); 
     358        } 
     359 
     360        this.fireEvent("rowdeselect", this, index, record); 
     361        this.fireEvent("selectionchange", this); 
     362    }, 
     363 
     364    /** 
    318365     * Deselects a row. 
    319366     * @param {Number} row The index of the row to deselect 
     
    378425                this.grid.getView().onRowSelect(index); 
    379426            } 
     427 
    380428            this.fireEvent("rowselect", this, index, r); 
    381429            this.fireEvent("selectionchange", this); 
  • trunk/src/Store.js

    r26 r31  
    77 * license. 
    88 * 
    9  * Commercial use is prohibited. Contact "Thorsten Suckow-Homberg" <ts@siteartwork.de> 
    10  * if you need a commercial license. 
     9 * Commercial use is prohibited. Visit <http://www.siteartwork.de/livegrid> 
     10 * if you need to obtain a commercial license. 
    1111 * 
    1212 * This program is free software: you can redistribute it and/or modify it under 
     
    2222 * this program. If not, see <http://www.gnu.org/licenses/gpl.html>. 
    2323 * 
    24  * If you would like to support the development and support of the Ext.ux.Livegrid 
    25  * component, you can make a donation: <http://www.siteartwork.de/livegrid> 
    2624 */ 
    2725 
     
    570568        //anything buffered yet? 
    571569        if (this.bufferRange[0] == -1) { 
    572             return -1; 
    573         } 
     570            return undefined; 
     571        } 
     572 
    574573        var modelIndex = index - this.bufferRange[0]; 
    575574        return this.data.itemAt(modelIndex); 
  • trunk/src/Toolbar.js

    r26 r31  
    77 * license. 
    88 * 
    9  * Commercial use is prohibited. Contact "Thorsten Suckow-Homberg" <ts@siteartwork.de> 
    10  * if you need a commercial license. 
     9 * Commercial use is prohibited. Visit <http://www.siteartwork.de/livegrid> 
     10 * if you need to obtain a commercial license. 
    1111 * 
    1212 * This program is free software: you can redistribute it and/or modify it under 
     
    2222 * this program. If not, see <http://www.gnu.org/licenses/gpl.html>. 
    2323 * 
    24  * If you would like to support the development and support of the Ext.ux.Livegrid 
    25  * component, you can make a donation: <http://www.siteartwork.de/livegrid> 
    2624 */ 
    2725 
     
    4139 */ 
    4240Ext.ux.grid.livegrid.Toolbar = Ext.extend(Ext.Toolbar, { 
     41 
     42    /** 
     43     * @cfg {Ext.grid.GridPanel} grid 
     44     * The grid the toolbar is bound to. If ommited, use the cfg property "view" 
     45     */ 
     46 
     47    /** 
     48     * @cfg {Ext.grid.GridView} view The view the toolbar is bound to 
     49     * The grid the toolbar is bound to. If ommited, use the cfg property "grid" 
     50     */ 
     51 
    4352    /** 
    4453     * @cfg {Boolean} displayInfo 
     
    6877    { 
    6978        Ext.ux.grid.livegrid.Toolbar.superclass.initComponent.call(this); 
    70         this.bind(this.grid); 
     79 
     80        if (this.grid) { 
     81            this.bind(this.grid.getView()); 
     82        } else if (this.view) { 
     83            var me = this; 
     84            this.view.init = this.view.init.createSequence(function(){ 
     85                me.bind(this); 
     86            }, this.view); 
     87        } else { 
     88            throw("Ext.ux.grid.livegrid.Toolbar - cfg property view or grid is not available"); 
     89        } 
    7190    }, 
    7291 
     
    84103 
    85104    /** 
    86      * Unbinds the toolbar from the specified {@link Ext.ux.grid.Livegrid} 
    87      * @param {@link Ext.ux.grid.Livegrid} view The view to unbind 
    88      */ 
    89     unbind : function(grid) 
    90     { 
    91         var st = grid.getStore(); 
    92         var vw = grid.view; 
     105     * Unbinds the toolbar. 
     106     * 
     107     * @param {Ext.grid.GridView|Ext.gid.GridPanel} view Either The view to unbind 
     108     * or the grid 
     109     */ 
     110    unbind : function(view) 
     111    { 
     112        var st; 
     113        var vw; 
     114 
     115        if (view instanceof Ext.grid.GridView) { 
     116            vw = view; 
     117        } else { 
     118            // assuming parameter is of type Ext.grid.GridPanel 
     119            vw = view.getView(); 
     120        } 
     121 
     122        st = view.ds; 
    93123 
    94124        st.un('loadexception', this.enableLoading,  this); 
     
    101131        vw.un('buffer',        this.onBuffer,       this); 
    102132        vw.un('bufferfailure', this.enableLoading,  this); 
    103         this.grid = undefined; 
     133 
     134        this.view = undefined; 
    104135    }, 
    105136 
    106137    /** 
    107138     * Binds the toolbar to the specified {@link Ext.ux.grid.Livegrid} 
    108      * @param {Ext.ux.grid.Livegrid} view The view to bind 
    109      */ 
    110     bind : function(grid) 
    111     { 
    112         var st = grid.getStore(); 
    113         var vw = grid.view; 
    114  
    115         st.on('loadexception', this.enableLoading,  this); 
    116         st.on('beforeload',    this.disableLoading, this); 
    117         st.on('load',          this.enableLoading, this); 
    118         vw.on('rowremoved',    this.onRowRemoved,   this); 
    119         vw.on('rowsinserted',  this.onRowsInserted, this); 
    120         vw.on('beforebuffer',  this.beforeBuffer,  this); 
    121         vw.on('cursormove',    this.onCursorMove,   this); 
    122         vw.on('buffer',        this.onBuffer,       this); 
    123         vw.on('bufferfailure', this.enableLoading,  this); 
    124         this.grid = grid; 
     139     * 
     140     * @param {Ext.grird.GridView} view The view to bind 
     141     */ 
     142    bind : function(view) 
     143    { 
     144        this.view = view; 
     145        var st = view.ds; 
     146 
     147        st.on('loadexception',   this.enableLoading, this); 
     148        st.on('beforeload',      this.disableLoading, this); 
     149        st.on('load',            this.enableLoading,  this); 
     150        view.on('rowremoved',    this.onRowRemoved,  this); 
     151        view.on('rowsinserted',  this.onRowsInserted, this); 
     152        view.on('beforebuffer',  this.beforeBuffer,   this); 
     153        view.on('cursormove',    this.onCursorMove,   this); 
     154        view.on('buffer',        this.onBuffer,       this); 
     155        view.on('bufferfailure', this.enableLoading,  this); 
    125156    }, 
    126157 
     
    174205        switch (type) { 
    175206            case 'refresh': 
    176                 if (this.grid.view.reset(true)) { 
     207                if (this.view.reset(true)) { 
    177208                    this.loading.disable(); 
    178209                } else {