PDA

View Full Version : Combobox setReadOnly() function too slow!



byu_risk3
20 Jul 2012, 8:22 AM
Extjs Version: 4.1.0

I was wondering why the setReadOnly() function is so slow.

When you use setReadOnly() on a combo box, it has to re-render it in order to remove the trigger button.

It takes about 2 or 3 seconds for this for loop to finish with a mere 6 items and render it to the screen...



var cq = Ext.ComponentQuery;
var comboboxes = cq.query( "invenform combobox" );

for( var i = 0; i < comboboxes.length; i++ ){
comboboxes[ i ].setReadOnly( false );
comboboxes[ i ].forceSelection = true;
};


I was wondering if anyone had any ideas as to why this is so slow. Am I doing something inefficient? Is it the rendering that takes so long? Is Extjs 4's setReadOnly() function just not optimized?

Thanks.

byu_risk3
20 Jul 2012, 9:04 AM
Update:

So, it turns out that any textfield takes quite a bit of time to process when using setReadOnly(), not just the comboboxes.

scottmartin
20 Jul 2012, 12:22 PM
Have you tried using suspendLayouts on your container?

form.suspendLayouts()
// update fields
form.resumeLayouts(true);
form.doLayout()

there is also a global version Ext.suspendLayouts()

Scott.

byu_risk3
20 Jul 2012, 1:25 PM
Thanks Scott! It works like a charm.