如何将flex ComboBox提示属性设置为空字符串

发布于 2024-11-16 04:00:53 字数 251 浏览 5 评论 0原文

这是我的代码:

<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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

微暖i 2024-11-23 04:00:53

我建议不要使用 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.

゛时过境迁 2024-11-23 04:00:53

我能够使用以下代码修复此问题,而无需修改 dataProvider:

combobox1.dataProvider = tableSelector.list;
combobox1.selectedIndex = -1;

I was able to fix this without modifying the dataProvider with this code:

combobox1.dataProvider = tableSelector.list;
combobox1.selectedIndex = -1;
梦断已成空 2024-11-23 04:00:53

+J_A_X 答案,并检查

requireSelection="false"

哪个对 Spark DropDownList 有效...

+J_A_X answer, and check

requireSelection="false"

which is valid for Spark DropDownList ...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文