this.el.update("");
var html = [];
var records = this.store.getRange();
- if(records.length < 1){
+ if(records.length < 1) {
+
+ // is this valid?? = should it render a template??
+
this.el.update(this.emptyText);
return;
}
-
+ var el = this.el;
+ if (this.dataName) {
+ this.el.update(t.apply(this.store.meta)); //????
+ el = this.el.child('.roo-tpl-' + this.dataName);
+ }
for(var i = 0, len = records.length; i < len; i++){
var data = this.prepareData(records[i].data, i, records[i]);
this.fireEvent("preparedata", this, data, i, records[i]);
- html[html.length] = Roo.util.Format.trim( t.apply(data) );
+ html[html.length] = Roo.util.Format.trim(
+ this.dataName ?
+ t.applySubtemplate(this.dataName, data, this.store.meta) :
+ t.apply(data)
+ );
}
- this.el.update(html.join(""));
- this.nodes = this.el.dom.childNodes;
+ el.update(html.join(""));
+ this.nodes = el.dom.childNodes;
this.updateIndexes(0);
},
/**
* Function to override to reformat the data that is sent to
* the template for each node.
+ * DEPRICATED - use the preparedata event handler.
* @param {Array/Object} data The raw data (array of colData for a data model bound view or
* a JSON object for an UpdateManager bound view).
*/
- prepareData : function(data){
- this.fireEvent("preparedata", this, data);
+ prepareData : function(data, index, record)
+ {
+ this.fireEvent("preparedata", this, data, index, record);
return data;
},
this.clearSelections();
var index = this.store.indexOf(record);
var n = this.nodes[index];
- this.tpl.insertBefore(n, this.prepareData(record.data));
+ this.tpl.insertBefore(n, this.prepareData(record.data, index, record));
n.parentNode.removeChild(n);
this.updateIndexes(index, index);
},
- onAdd : function(ds, records, index){
+
+
+// --------- FIXME
+ onAdd : function(ds, records, index)
+ {
this.clearSelections();
if(this.nodes.length == 0){
this.refresh();
}
var n = this.nodes[index];
for(var i = 0, len = records.length; i < len; i++){
- var d = this.prepareData(records[i].data);
+ var d = this.prepareData(records[i].data, i, records[i]);
if(n){
this.tpl.insertBefore(n, d);
}else{
+
this.tpl.append(this.el, d);
}
}
onRemove : function(ds, record, index){
this.clearSelections();
- this.el.dom.removeChild(this.nodes[index]);
+ var el = this.dataName ?
+ this.el.child('.roo-tpl-' + this.dataName) :
+ this.el;
+ el.dom.removeChild(this.nodes[index]);
this.updateIndexes(index);
},
* @return {HTMLElement} The template node
*/
findItemFromChild : function(node){
- var el = this.el.dom;
+ var el = this.dataName ?
+ this.el.child('.roo-tpl-' + this.dataName,true) :
+ this.el.dom;
+
if(!node || node.parentNode == el){
return node;
}