</head>
<body onload="prettyPrint();">
<pre class="prettyprint lang-js">/*!
- * Ext JS Library 3.2.0
- * Copyright(c) 2006-2010 Ext JS, Inc.
- * 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
*/
<div id="cls-Ext.DataView"></div>/**
* @class Ext.DataView
*/
refresh : function() {
this.clearSelections(false, true);
- var el = this.getTemplateTarget();
- el.update("");
- var records = this.store.getRange();
+ var el = this.getTemplateTarget(),
+ records = this.store.getRange();
+
+ el.update('');
if(records.length < 1){
if(!this.deferEmptyText || this.hasSkippedEmptyText){
el.update(this.emptyText);
* contain <i>named</i> properties.
*/
collectData : function(records, startIndex){
- var r = [];
- for(var i = 0, len = records.length; i < len; i++){
- r[r.length] = this.prepareData(records[i].data, startIndex+i, records[i]);
+ var r = [],
+ i = 0,
+ len = records.length;
+ for(; i < len; i++){
+ r[r.length] = this.prepareData(records[i].data, startIndex + i, records[i]);
}
return r;
},
// private
- bufferRender : function(records){
+ bufferRender : function(records, index){
var div = document.createElement('div');
- this.tpl.overwrite(div, this.collectData(records));
+ this.tpl.overwrite(div, this.collectData(records, index));
return Ext.query(this.itemSelector, div);
},
onUpdate : function(ds, record){
var index = this.store.indexOf(record);
if(index > -1){
- var sel = this.isSelected(index);
- var original = this.all.elements[index];
- var node = this.bufferRender([record], index)[0];
+ var sel = this.isSelected(index),
+ original = this.all.elements[index],
+ node = this.bufferRender([record], index)[0];
this.all.replaceElement(index, node, true);
if(sel){
// private
onClick : function(e){
- var item = e.getTarget(this.itemSelector, this.getTemplateTarget());
+ var item = e.getTarget(this.itemSelector, this.getTemplateTarget()),
+ index;
if(item){
- var index = this.indexOf(item);
+ index = this.indexOf(item);
if(this.onItemClick(item, index, e) !== false){
this.fireEvent("click", this, index, item, e);
}
* @return {Array} An array of numeric indexes
*/
getSelectedIndexes : function(){
- var indexes = [], s = this.selected.elements;
- for(var i = 0, len = s.length; i < len; i++){
- indexes.push(s[i].viewIndex);
+ var indexes = [],
+ selected = this.selected.elements,
+ i = 0,
+ len = selected.length;
+
+ for(; i < len; i++){
+ indexes.push(selected[i].viewIndex);
}
return indexes;
},
* @return {Array} An array of {@link Ext.data.Record} objects
*/
getSelectedRecords : function(){
- var r = [], s = this.selected.elements;
- for(var i = 0, len = s.length; i < len; i++){
- r[r.length] = this.store.getAt(s[i].viewIndex);
- }
- return r;
+ return this.getRecords(this.selected.elements);
},
<div id="method-Ext.DataView-getRecords"></div>/**
* @return {Array} records The {@link Ext.data.Record} objects
*/
getRecords : function(nodes){
- var r = [], s = nodes;
- for(var i = 0, len = s.length; i < len; i++){
- r[r.length] = this.store.getAt(s[i].viewIndex);
+ var records = [],
+ i = 0,
+ len = nodes.length;
+
+ for(; i < len; i++){
+ records[records.length] = this.store.getAt(nodes[i].viewIndex);
}
- return r;
+ return records;
},
<div id="method-Ext.DataView-getRecord"></div>/**
* @return {Array} An array of nodes
*/
getNodes : function(start, end){
- var ns = this.all.elements;
+ var ns = this.all.elements,
+ nodes = [],
+ i;
+
start = start || 0;
end = !Ext.isDefined(end) ? Math.max(ns.length - 1, 0) : end;
- var nodes = [], i;
if(start <= end){
for(i = start; i <= end && ns[i]; i++){
nodes.push(ns[i]);