PDA

View Full Version : [2.0a1][CLOSED] ComboBox Resize



lstroud
1 Oct 2007, 11:10 AM
I have been able to work around it. However, I had some difficulty with combo resizing. I tried setting grow to true. However, it seemed to always cut about a letter off of my data. (that may be the actual bug here). I then tried setting the width, that only seems to effect the size of the list and not the box itself. Ultimately, I had to do the following:



this.ccncombo = new Ext.form.ComboBox({
renderTo: 'ccn',
store: this.ccnstore,
displayField:'description',
valueField: 'id',
typeAhead: false,
forceSelection: true,
readOnly: true,
// grow: true,
// growMax: 1000,
// growMin: 30,
mode: 'local',
triggerAction: 'all',
emptyText:'Select a ccn...',
selectOnFocus:true
//height: 19
});



setCcns : function(ccnXml){
var prefs = Framework.getUser().preferences;

if(prefs.showCcnName){
this.ccncombo.displayField = "description";
this.ccncombo.el.setWidth("209");
this.ccncombo.setWidth("235");
}
else{
this.ccncombo.displayField = "id";
this.ccncombo.el.setWidth("74");
this.ccncombo.setWidth("100");
}

this.ccns = ccnXml;
this.ccnstore.proxy.data = ccnXml;
this.ccnstore.reload();

//if only one ccn then remove the combo box and use a label instead
if(this.ccnstore.getCount() < 2){
this.ccncombo.hide();
var ccnEl = Ext.get("ccn");
var theccn;
if(prefs.showCcnName)
theccn = this.ccnstore.getAt(0).description;
else
theccn = this.ccnstore.getAt(0).id;
Ext.DomHelper.append(ccnEl, "<span id='ccnName'>" + theccn + "</span>");
}else{
Ext.DomHelper.insertFirst(this.ccncombo.el, "<span id='ccnIdentifier'>Ccn: </span>")
}
this.doLayout();
},


It's low hanging fruit, but it would be nice if there were a reliable way to expand the width of a combo based on the data. (Of course, I could be doing something wrong :)).

LES

jack.slocum
1 Oct 2007, 6:00 PM
grow is not compatible with any subclass of TriggerField. That's why the options are hidden in the docs. There is much more that goes into the sizing of a TriggerField and dynamic sizing on keystrokes wouldn't net very good performance, and causes rendering issues particularly in IE.

lstroud
2 Oct 2007, 2:43 AM
Is there a good way of adjusting the size of the combo box manually? I tried setting the width, but that only seems to effect the list and not the actual combo box.

LES

jack.slocum
2 Oct 2007, 3:08 AM
setWidth(number) will do it (inherited from BoxComponent)

lstroud
2 Oct 2007, 8:33 AM
Hmmm...I'll try that again, but that is what I tried before and while it changed the width of the list, it did not change the width of the component (the drop down box itself). I was dev-ing on firefox 2 on linux. I'll try it on some other platforms and see if it was specific to this one.

Thanx,
LES