ExtJS TabPanel SetActiveTab Reverting back to 0 -


i have tabpanel can click button create new tabs. when button click creates new tab not issue, when call setactivetab appears nothing. when stepped through in chrome can see changing tab specified 1 switching original. great. here code:

tab control:

{                 xtype:'tabpanel',                 itemid:'tabctr1',                 width:785,                 hidden:true,                 items:[                     { iconcls: 'btn-newtab', tabconfig: { listeners: { click: btnaddsensor_click } } }                 ]             } 

click event:

function btnaddsensor_click(sender,e,eopts) { //local variable declaration var parent = sender.up('tabpanel');  if (parent !== null && parent !== undefined) {     var newtab = parent.add({         title: parent.items.length,         layout: 'vbox',          width:785,          margin:'5 0 0 0',         items:[                  ]             }         ]     });      parent.setactivetab(newtab); } } 

it appaers timing issue , able resolve using:

ext.function.defer(function(p){ p.setactivetab((parent.items.getcount()-1)); }, 1000, this, [parent]); 

Comments

Popular posts from this blog

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - UML - How would you draw a try catch in a sequence diagram? -

c++ - No viable overloaded operator for references a map -