Actionscript 3 灵活可编辑组合框
我正在为我的应用程序使用可编辑的组合框。Combobox具有如下默认行为 如果我输入了一些与combobox dataprovider值不相似的文本,combobox默认情况下选择FirstDataProvider值并关闭下拉窗口。我想停止这种默认行为 例如,我有一个带有dataprovider值的组合框。(堆栈、堆栈溢出、堆栈溢出A) 我打开下拉列表,看到“stackoverflow A”值在下拉列表中。现在我输入值“stackoverflow B”,但该值不在下拉列表中,因此当我输入时,combobox将覆盖我输入的文本,并用数据提供程序(下拉列表)“stack”的第一个值替换“stackoverflow B”,并触发selectedindex更改事件。我想在默认情况下停止选择第一个值的组合框的默认行为,并查找输入的值 我已经尝试过在默认情况下将selectedindex设置为-1,但默认情况下仍然使用第一个值。任何解决方法或建议都会有所帮助Actionscript 3 灵活可编辑组合框,actionscript-3,apache-flex,flex4,flex3,adobe,Actionscript 3,Apache Flex,Flex4,Flex3,Adobe,我正在为我的应用程序使用可编辑的组合框。Combobox具有如下默认行为 如果我输入了一些与combobox dataprovider值不相似的文本,combobox默认情况下选择FirstDataProvider值并关闭下拉窗口。我想停止这种默认行为 例如,我有一个带有dataprovider值的组合框。(堆栈、堆栈溢出、堆栈溢出A) 我打开下拉列表,看到“stackoverflow A”值在下拉列表中。现在我输入值“stackoverflow B”,但该值不在下拉列表中,因此当我输入时,co
谢谢我想这会对你有所帮助
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" horizontalAlign="center"
verticalAlign="middle" height="100%" width="100%">
<mx:Script>
<![CDATA[
public var arr:Array = new Array({isSelected:true,label:'ABC',score:'78',name:'ABC'},
{isSelected:true,label:'DEF',score:'50',name:'DEF'},
{isSelected:false,label:'GHI',score:'70',name:'GHI'},
{isSelected:false,label:'JKL',score:'80',name:'JKL'},
{isSelected:true,label:'TRE',score:'50',name:'MNO'});
public function dgCLG_dataChange():void
{
}
public function dgCLG_change():void
{
}
public function btnSubmit_click():void
{
dgCopy.dataProvider = dgCLG.dataProvider;
}
]]>
</mx:Script>
<mx:VBox height="100%" width="100%" horizontalAlign="center" verticalAlign="middle">
<mx:DataGrid id="dgCLG" dataProvider="{arr}" editable="true" dataChange="{dgCLG_dataChange();}" change="{dgCLG_change();}">
<mx:columns>
<mx:DataGridColumn headerText="" dataField="isSelected">
<mx:itemRenderer>
<mx:Component>
<mx:Box horizontalAlign="center" verticalAlign="middle" height="100%" width="100%">
<mx:Script>
<![CDATA[
override public function set data(value:Object):void
{
if(value != null)
{
super.data = value;
var temp:Object = value as Object;
chb.selected = temp.isSelected;
}
}
]]>
</mx:Script>
<mx:CheckBox id="chb"/>
</mx:Box>
</mx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>
<mx:DataGridColumn headerText="Label" dataField="label" editable="false">
</mx:DataGridColumn>
<mx:DataGridColumn dataField="name" headerText="Person" itemEditor="ComCB" editorDataField="value" editable="true">
</mx:DataGridColumn>
</mx:columns>
</mx:DataGrid>
<mx:Button id="btnSubmit" label="Click" click="{btnSubmit_click();}" />
<mx:DataGrid id="dgCopy" editable="false">
<mx:columns>
<mx:DataGridColumn headerText="CopyLabel" dataField="label" />
<mx:DataGridColumn headerText="CopyMarks" dataField="score" />
<mx:DataGridColumn headerText="CopyPerson" dataField="name" />
</mx:columns>
</mx:DataGrid>
</mx:VBox>
</mx:Application>
这是ComCb组件
<?xml version="1.0" encoding="utf-8"?>
<mx:ComboBox xmlns:mx="http://www.adobe.com/2006/mxml" dataProvider="{arr}" selectedIndex="1" creationComplete="{c_complete();}" >
<mx:Script>
<![CDATA[
public var arr:Array = new Array({label:'ABC'},{label:'DEF'},{label:'GHI'},{label:'JKL'},{label:'MNO'},{label:'XXX'})
public function c_complete():void
{
for(var i:int = 0; i < arr.length; i++)
{
if(arr[i].label == parentDocument.dgCLG.selectedItem.name)
{
this.selectedItem = arr[i];
}
}
}
]]>
</mx:Script>
</mx:ComboBox>
也许这会对你有帮助
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" horizontalAlign="center"
verticalAlign="middle" height="100%" width="100%">
<mx:Script>
<![CDATA[
public var arr:Array = new Array({isSelected:true,label:'ABC',score:'78',name:'ABC'},
{isSelected:true,label:'DEF',score:'50',name:'DEF'},
{isSelected:false,label:'GHI',score:'70',name:'GHI'},
{isSelected:false,label:'JKL',score:'80',name:'JKL'},
{isSelected:true,label:'TRE',score:'50',name:'MNO'});
public function dgCLG_dataChange():void
{
}
public function dgCLG_change():void
{
}
public function btnSubmit_click():void
{
dgCopy.dataProvider = dgCLG.dataProvider;
}
]]>
</mx:Script>
<mx:VBox height="100%" width="100%" horizontalAlign="center" verticalAlign="middle">
<mx:DataGrid id="dgCLG" dataProvider="{arr}" editable="true" dataChange="{dgCLG_dataChange();}" change="{dgCLG_change();}">
<mx:columns>
<mx:DataGridColumn headerText="" dataField="isSelected">
<mx:itemRenderer>
<mx:Component>
<mx:Box horizontalAlign="center" verticalAlign="middle" height="100%" width="100%">
<mx:Script>
<![CDATA[
override public function set data(value:Object):void
{
if(value != null)
{
super.data = value;
var temp:Object = value as Object;
chb.selected = temp.isSelected;
}
}
]]>
</mx:Script>
<mx:CheckBox id="chb"/>
</mx:Box>
</mx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>
<mx:DataGridColumn headerText="Label" dataField="label" editable="false">
</mx:DataGridColumn>
<mx:DataGridColumn dataField="name" headerText="Person" itemEditor="ComCB" editorDataField="value" editable="true">
</mx:DataGridColumn>
</mx:columns>
</mx:DataGrid>
<mx:Button id="btnSubmit" label="Click" click="{btnSubmit_click();}" />
<mx:DataGrid id="dgCopy" editable="false">
<mx:columns>
<mx:DataGridColumn headerText="CopyLabel" dataField="label" />
<mx:DataGridColumn headerText="CopyMarks" dataField="score" />
<mx:DataGridColumn headerText="CopyPerson" dataField="name" />
</mx:columns>
</mx:DataGrid>
</mx:VBox>
</mx:Application>
祝你愉快D@y.......我想这会对你有所帮助
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" horizontalAlign="center"
verticalAlign="middle" height="100%" width="100%">
<mx:Script>
<![CDATA[
public var arr:Array = new Array({isSelected:true,label:'ABC',score:'78',name:'ABC'},
{isSelected:true,label:'DEF',score:'50',name:'DEF'},
{isSelected:false,label:'GHI',score:'70',name:'GHI'},
{isSelected:false,label:'JKL',score:'80',name:'JKL'},
{isSelected:true,label:'TRE',score:'50',name:'MNO'});
public function dgCLG_dataChange():void
{
}
public function dgCLG_change():void
{
}
public function btnSubmit_click():void
{
dgCopy.dataProvider = dgCLG.dataProvider;
}
]]>
</mx:Script>
<mx:VBox height="100%" width="100%" horizontalAlign="center" verticalAlign="middle">
<mx:DataGrid id="dgCLG" dataProvider="{arr}" editable="true" dataChange="{dgCLG_dataChange();}" change="{dgCLG_change();}">
<mx:columns>
<mx:DataGridColumn headerText="" dataField="isSelected">
<mx:itemRenderer>
<mx:Component>
<mx:Box horizontalAlign="center" verticalAlign="middle" height="100%" width="100%">
<mx:Script>
<![CDATA[
override public function set data(value:Object):void
{
if(value != null)
{
super.data = value;
var temp:Object = value as Object;
chb.selected = temp.isSelected;
}
}
]]>
</mx:Script>
<mx:CheckBox id="chb"/>
</mx:Box>
</mx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>
<mx:DataGridColumn headerText="Label" dataField="label" editable="false">
</mx:DataGridColumn>
<mx:DataGridColumn dataField="name" headerText="Person" itemEditor="ComCB" editorDataField="value" editable="true">
</mx:DataGridColumn>
</mx:columns>
</mx:DataGrid>
<mx:Button id="btnSubmit" label="Click" click="{btnSubmit_click();}" />
<mx:DataGrid id="dgCopy" editable="false">
<mx:columns>
<mx:DataGridColumn headerText="CopyLabel" dataField="label" />
<mx:DataGridColumn headerText="CopyMarks" dataField="score" />
<mx:DataGridColumn headerText="CopyPerson" dataField="name" />
</mx:columns>
</mx:DataGrid>
</mx:VBox>
</mx:Application>
这是ComCb组件
<?xml version="1.0" encoding="utf-8"?>
<mx:ComboBox xmlns:mx="http://www.adobe.com/2006/mxml" dataProvider="{arr}" selectedIndex="1" creationComplete="{c_complete();}" >
<mx:Script>
<![CDATA[
public var arr:Array = new Array({label:'ABC'},{label:'DEF'},{label:'GHI'},{label:'JKL'},{label:'MNO'},{label:'XXX'})
public function c_complete():void
{
for(var i:int = 0; i < arr.length; i++)
{
if(arr[i].label == parentDocument.dgCLG.selectedItem.name)
{
this.selectedItem = arr[i];
}
}
}
]]>
</mx:Script>
</mx:ComboBox>
也许这会对你有帮助
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" horizontalAlign="center"
verticalAlign="middle" height="100%" width="100%">
<mx:Script>
<![CDATA[
public var arr:Array = new Array({isSelected:true,label:'ABC',score:'78',name:'ABC'},
{isSelected:true,label:'DEF',score:'50',name:'DEF'},
{isSelected:false,label:'GHI',score:'70',name:'GHI'},
{isSelected:false,label:'JKL',score:'80',name:'JKL'},
{isSelected:true,label:'TRE',score:'50',name:'MNO'});
public function dgCLG_dataChange():void
{
}
public function dgCLG_change():void
{
}
public function btnSubmit_click():void
{
dgCopy.dataProvider = dgCLG.dataProvider;
}
]]>
</mx:Script>
<mx:VBox height="100%" width="100%" horizontalAlign="center" verticalAlign="middle">
<mx:DataGrid id="dgCLG" dataProvider="{arr}" editable="true" dataChange="{dgCLG_dataChange();}" change="{dgCLG_change();}">
<mx:columns>
<mx:DataGridColumn headerText="" dataField="isSelected">
<mx:itemRenderer>
<mx:Component>
<mx:Box horizontalAlign="center" verticalAlign="middle" height="100%" width="100%">
<mx:Script>
<![CDATA[
override public function set data(value:Object):void
{
if(value != null)
{
super.data = value;
var temp:Object = value as Object;
chb.selected = temp.isSelected;
}
}
]]>
</mx:Script>
<mx:CheckBox id="chb"/>
</mx:Box>
</mx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>
<mx:DataGridColumn headerText="Label" dataField="label" editable="false">
</mx:DataGridColumn>
<mx:DataGridColumn dataField="name" headerText="Person" itemEditor="ComCB" editorDataField="value" editable="true">
</mx:DataGridColumn>
</mx:columns>
</mx:DataGrid>
<mx:Button id="btnSubmit" label="Click" click="{btnSubmit_click();}" />
<mx:DataGrid id="dgCopy" editable="false">
<mx:columns>
<mx:DataGridColumn headerText="CopyLabel" dataField="label" />
<mx:DataGridColumn headerText="CopyMarks" dataField="score" />
<mx:DataGridColumn headerText="CopyPerson" dataField="name" />
</mx:columns>
</mx:DataGrid>
</mx:VBox>
</mx:Application>
祝你愉快D@y.......有一种替代方法,它不尝试将文本与数据提供程序值匹配(如上所述),并且没有。它是一个ActionScript、Flex、spark-only组合框,可作为提供。有一个替代选项,它不尝试将文本与数据提供程序值匹配(如上所述),并且没有。这是一个ActionScript、Flex、spark-only组合框,可作为提供。我不完全了解正在发生什么,也不完全了解您希望发生什么。不过,我认为这个问题的视频屏幕截图会非常有帮助。我不能放截图,但我试着再次解释。这解释得更好。我认为您必须深入研究代码并对其进行扩展;因为似乎没有解决这类问题的属性。我不完全理解正在发生的事情,也不完全理解您希望发生的事情。不过,我认为这个问题的视频屏幕截图会非常有帮助。我不能放截图,但我试着再次解释。这解释得更好。我认为您必须深入研究代码并对其进行扩展;因为似乎没有解决这类问题的属性。