PDA

View Full Version : XTemplate <tpl for="number">?



js_coder
17 Feb 2010, 2:24 PM
Is there a way to provide a number to a <tpl for="n"> tag so that its contents are repeated n times? I'd rather not have to create mock arrays for that.

Edit: Although this is useful for such a thing:


Ext.range = function(a, b) {
var range = [];
for(var i = a; i <= b; i++) {
range.push(i);
}
return range;
};

js_coder
18 Feb 2010, 6:15 AM
So...no?

mchugh
20 Nov 2014, 2:52 AM
Found this when searching for the same thing. I can't see any way to do it, except to cheat and just use js. For example:


tpl: Ext.create('Ext.XTemplate',
'[{this.createDivs(4)}]',
{
createDivs: function(numDivs) {
var html = "";
for (var i = 0; i < numDivs; i++) {
html += "<div></div>";
}
return html;
}
});