PDA

View Full Version : Problem Populating a Menu with CheckItems



crisboot
17 Mar 2010, 1:18 PM
Hello,
I think this is a bug, I'am using Ext JS 3.1.1, and I have this problem when I populate the menu this way:


var mb = new Ext.Toolbar.Button({
text: "T.button",
menu:[],
renderTo: document.body
});


var ds = new Ext.data.Store({
data: [
['1','Better Data','false', 'quality2'],
['2','Good Data','false', 'quality2'],
['3','Best Data','true', 'quality2']
],
reader: new Ext.data.ArrayReader({}, ['id', 'text', 'checked', 'group'])
});

ds.data.each(function() {
var booleana;
if(this.data['checked']=='false'){booleana = false;}else{booleana = true;};
mb.menu.items.add(
new Ext.menu.CheckItem({
fieldLabel: this.data['text'],
text: this.data['text'],
checked:booleana,
group:this.data['group']})
);
});



The menu is allready populated but the selection in not changing...:-?

I have test this code in version 2.2.1 and it was working good, I've add listeners on click, and click work fine, but is not firing checkchange event.

Can someone reproduce this error, the console is not firing any error, may be it is something more global... I have been looking at the Toolbar.js, and now the T.Button it is just a button and mainteined only for compatibility... it isn't at the new API documentation, but why this is happening?

I've add some listeners, to figure out what was happening and I only obtain clicks


mb.menu.items.add( new Ext.menu.CheckItem({
text: this.data['text'],
checked:booleana,
group:this.data['group'],
listeners:{
click:function(){
console.log("Click!");
},
checkchange: function(){
console.log("Check Change!");
}
}}));



Pleasee help!!!