PDA

View Full Version : method [get] returns [undefined]



MorliDots
20 Sep 2013, 3:16 AM
var container1 = Ext.create('Ext.container.Container');
var container2 = Ext.create('Ext.container.Container');
container1.items.add(Ext.create('Ext.panel.Panel',{title: '1'}));
container1.items.add(Ext.create('Ext.panel.Panel',{title: '2'}));
console.log('count.c1 = '+container1.items.getCount()); = 2
var ts = container1.items.removeAt(0);
console.log('count.c1 = '+container1.items.getCount()); = 1
console.info(ts); = [Object]
console.log('count.c2 = '+container2.items.getCount()); = 0
container2.items.add(ts);
console.log('count.c2 = '+container2.items.getCount()); = 1
var rt = container2.items.get(ts);
console.info(rt); !!!! undefined !!!

why the value is undefined?

console.info(container2.items.getAt(0)); = the same object [Object]

Gary Schlosberg
20 Sep 2013, 3:48 PM
The get (http://docs.sencha.com/extjs/4.2.1/#!/api/Ext.util.AbstractMixedCollection-method-get) method doesn't accept an object as argument, rather an index or a key. So you might change the second to last line to use the key:


var rt = container2.items.get(ts.id);