如何将flex ComboBox提示属性设置为空字符串
这是我的代码:
<mx:ComboBox prompt="" editable="true" dataProvider="{tableSelector.list}"/>
当此代码执行时,flex 只是将 selectedIndex 设置为 0 并显示 dataProvider 中的第一项,而不是将文本和提示保留为空字符串“”。我该如何解决这个问题?我需要文本属性为“”,除非用户选择组合框中的另一个项目。
Here is my code:
<mx:ComboBox prompt="" editable="true" dataProvider="{tableSelector.list}"/>
When this code executes, flex just sets the selectedIndex to 0 and displays the first item in the dataProvider instead of leaving the text and prompt as the empty string "". How do I get around this? I need the text property to be "" unless the user selects another item in the combobox.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我建议不要使用 mx ComboBox,而是使用 Spark 等效项。使用 mx 组合框修复此问题的一种方法是仅使用空格或使用动作脚本来设置它,因为 mxml 将字符串信息解析为属性的方式。空字符串本质上等于 mxml 中的 null。
我想问为什么你需要一个空的组合框来开始。您可能只想使用数据提供程序中的空项目。
I would recommend not using the mx ComboBox and use the Spark equivalent instead. A way to fix this with the mx combobox would be to just use a space or use actionscript to set it because of the way mxml parses string info into properties. An empty string is essentially equal to null in mxml.
I would question as to why you need an empty combobox to start with. You might want to just use an empty item in the dataprovider instead.
我能够使用以下代码修复此问题,而无需修改 dataProvider:
I was able to fix this without modifying the dataProvider with this code:
+J_A_X 答案,并检查
哪个对 Spark DropDownList 有效...
+J_A_X answer, and check
which is valid for Spark DropDownList ...