PDA

View Full Version : loops in Extjs



olavevismaya
26 Aug 2010, 11:00 PM
hi......
how to use loops in Extjs
i want use loop to print 26 buttons for a to z in tbar
if any one knows solution or ideas help me

evant
26 Aug 2010, 11:04 PM
Well, if you did it manually, you'd use:



var toolbar = new Ext.Toolbar({
items: [{
text: 'a'
},{
text: 'b'
}, { // .......
text: 'z'
}]
});


So just write a loop to produce that same array!

olavevismaya
27 Aug 2010, 12:50 AM
how can i use loop here, can you explain

moegal
27 Aug 2010, 1:07 AM
you can use character codes. A-Z 65-90, a-z 97-122. This is just a snippet from a plugin I had found on the site. Do a forum search for GridAZFilter




for (var i=65; i<91; i++) {
items.push({
text: String.fromCharCode(i),
enableToggle: true,
toggleGroup: 'AZfilter',
toggleHandler: this.buttonToggleHandler,
scope: this
});
}


Marty

toogii
22 Nov 2012, 1:33 AM
Can you explain it in details bit more? where shall i use this loop?

brittongr
22 Nov 2012, 5:05 PM
You should add the code before the toolbar instance.


var yourItemsArray = [];

//loop
for(....)
{....}

var toolbar = new Ext.Toolbar({
items: yourItemsArray
});