我尝试使用dropdownWidth
属性,但它会是静态的。但如果数据太长,我就无法在下拉列表中看到全文。
所以我的要求是根据下拉项目文本的长宽度设置width
,以设置水平滚动条。
由于flex不支持水平滚动,我会覆盖Combobox类
<mx:FormItem id="zoneformitem" label="{Localizer.getString('zone','i18n')}" paddingLeft="60" paddingTop="15" required="true">
<mx:ComboBox id="selectedzone" open="campaigns.view.utils.CustomiZeCombo"
selectedIndex="-1"
dropdownWidth="210" width="209" change="validateZoneSelection()"
focusOut="validateZoneSelection()"
dataProvider="{slotProxy.slotWizardVo.currentZones.source.
sortOn('zoneName')}" >
<mx:itemRenderer>
<mx:Component>
public class CustomiZeCombo extends ComboBox{
public function CustomiZeCombo(){
super();
}
override public function open():void {
dropdown.horizontalScrollPolicy = ScrollPolicy.ON;
super.open();
}
override protected function
downArrowButton_buttonDownHandler(event:FlexEvent):void {
dropdown.horizontalScrollPolicy = ScrollPolicy.ON;
super.downArrowButton_buttonDownHandler(event);
}
}
但我没有得到如何调用该事件以使其工作。 建议非常感谢。
答案 0 :(得分:0)
尝试使用Click()甚至Combobox调用以下方法。
private function setWidthForLongdata():void {
var width:int;
width = selectedzone.width;
var maxWidth:int;
maxWidth = width + (width/2);
for each (var zone:ZoneVO in slotProxy.slotWizardVo.currentZones.source) {
if(zone.zoneName.length > maxLen ) {
maxLen = zone.zoneName.length;
}
}
if(maxLen*13 > width) {
width = maxLen*13;
if(width>maxWidth) {
width = maxWidth;
}
}
selectedzone.dropdown.width=width;
}