/*!
- * Ext JS Library 3.1.1
- * Copyright(c) 2006-2010 Ext JS, LLC
- * licensing@extjs.com
- * http://www.extjs.com/license
+ * Ext JS Library 3.3.1
+ * Copyright(c) 2006-2010 Sencha Inc.
+ * licensing@sencha.com
+ * http://www.sencha.com/license
*/
Ext.ns('Ext.ux.grid');
},
getVisibleRowCount : function(){
- var rh = this.getCalculatedRowHeight();
- var visibleHeight = this.scroller.dom.clientHeight;
+ var rh = this.getCalculatedRowHeight(),
+ visibleHeight = this.scroller.dom.clientHeight;
return (visibleHeight < 1) ? 0 : Math.ceil(visibleHeight / rh);
},
getVisibleRows: function(){
- var count = this.getVisibleRowCount();
- var sc = this.scroller.dom.scrollTop;
- var start = (sc == 0 ? 0 : Math.floor(sc/this.getCalculatedRowHeight())-1);
+ var count = this.getVisibleRowCount(),
+ sc = this.scroller.dom.scrollTop,
+ start = (sc === 0 ? 0 : Math.floor(sc/this.getCalculatedRowHeight())-1);
return {
first: Math.max(start, 0),
last: Math.min(start + count + 2, this.ds.getCount()-1)
},
doRender : function(cs, rs, ds, startRow, colCount, stripe, onlyBody){
- var ts = this.templates, ct = ts.cell, rt = ts.row, rb = ts.rowBody, last = colCount-1;
- var rh = this.getStyleRowHeight();
- var vr = this.getVisibleRows();
- var tstyle = 'width:'+this.getTotalWidth()+';height:'+rh+'px;';
- // buffers
- var buf = [], cb, c, p = {}, rp = {tstyle: tstyle}, r;
+ var ts = this.templates,
+ ct = ts.cell,
+ rt = ts.row,
+ rb = ts.rowBody,
+ last = colCount-1,
+ rh = this.getStyleRowHeight(),
+ vr = this.getVisibleRows(),
+ tstyle = 'width:'+this.getTotalWidth()+';height:'+rh+'px;',
+ // buffers
+ buf = [],
+ cb,
+ c,
+ p = {},
+ rp = {tstyle: tstyle},
+ r;
for (var j = 0, len = rs.length; j < len; j++) {
r = rs[j]; cb = [];
- var rowIndex = (j+startRow);
- var visible = rowIndex >= vr.first && rowIndex <= vr.last;
+ var rowIndex = (j+startRow),
+ visible = rowIndex >= vr.first && rowIndex <= vr.last;
if (visible) {
for (var i = 0; i < colCount; i++) {
c = cs[i];
p.id = c.id;
- p.css = i == 0 ? 'x-grid3-cell-first ' : (i == last ? 'x-grid3-cell-last ' : '');
+ p.css = i === 0 ? 'x-grid3-cell-first ' : (i == last ? 'x-grid3-cell-last ' : '');
p.attr = p.cellAttr = "";
p.value = c.renderer(r.data[c.name], p, r, rowIndex, i, ds);
p.style = c.style;
- if (p.value == undefined || p.value === "") {
+ if (p.value === undefined || p.value === "") {
p.value = " ";
}
if (r.dirty && typeof r.modified[c.name] !== 'undefined') {
}
}
var alt = [];
- if(stripe && ((rowIndex+1) % 2 == 0)){
+ if(stripe && ((rowIndex+1) % 2 === 0)){
alt[0] = "x-grid3-row-alt";
}
if(r.dirty){
doUpdate: function(){
if (this.getVisibleRowCount() > 0) {
- var g = this.grid, cm = g.colModel, ds = g.store;
- var cs = this.getColumnData();
-
- var vr = this.getVisibleRows();
+ var g = this.grid,
+ cm = g.colModel,
+ ds = g.store,
+ cs = this.getColumnData(),
+ vr = this.getVisibleRows(),
+ row;
for (var i = vr.first; i <= vr.last; i++) {
// if row is NOT rendered and is visible, render it
- if(!this.isRowRendered(i)){
+ if(!this.isRowRendered(i) && (row = this.getRow(i))){
var html = this.doRender(cs, [ds.getAt(i)], ds, i, cm.getColumnCount(), g.stripeRows, true);
- this.getRow(i).innerHTML = html;
+ row.innerHTML = html;
}
}
this.clean();
}
}
},
+
+ removeTask: function(name){
+ var task = this[name];
+ if(task && task.cancel){
+ task.cancel();
+ this[name] = null;
+ }
+ },
+
+ destroy : function(){
+ this.removeTask('cleanTask');
+ this.removeTask('renderTask');
+ Ext.ux.grid.BufferView.superclass.destroy.call(this);
+ },
layout: function(){
Ext.ux.grid.BufferView.superclass.layout.call(this);
this.update();
}
-});
+});
\ No newline at end of file