Friday, 15 April 2011

javascript - Adding component to container doesn't work -



javascript - Adding component to container doesn't work -

i hardly found easier illustration unknown reason have problems few lines of code. dynamically create buttons , add together them container end.

i don't know why first button added. please help

code:

var buttoncount = this.getfolderscontainer().query('button').length; var button = ext.create('ext.button.button'); button.id = 'folderbutton' + record.get('id'); button.settext(record.get('name') + " >>"); console.debug('count'); console.debug(buttoncount); this.getfolderscontainer().insert(buttoncount,button);

i created new blank project functionality , works fine. don't have clue causing in existing project.

first should sure buttons application wide unique id! next id should nowadays @ construction time of button (in case not critical recommend it). makes no sense when saying add() insert @ beginning, because insert @ end!

// ....getfolderscontainer().query('button').length; // count items!! // may check if id unique while debugging if(ext.getcmp('folderbutton' + record.get('id')) != null) console.error('id duplicated! >> ','folderbutton' + record.get('id')) var ct = this.getfolderscontainer(), itemcount = ct.items.getcount(), button = ext.create('ext.button.button', {text:record.get('name') + " >>",id:'folderbutton' + record.get('id')}); ct.insert(itemcount > 0 ? --itemcount : itemcount ,button); // if want insert @ end fine // ct.add(button);

javascript extjs

No comments:

Post a Comment