Flex Spark DropDownList - 在项目之间添加分隔符

发布于 2024-12-28 06:04:16 字数 199 浏览 5 评论 0原文

我正在尝试创建一个下拉列表,可以显示客户的过去状态和可能状态。

但我想在过去和可能的状态之间添加一个分隔符。

实际上,为了做到这一点,我在数据提供者上添加了一个类似“-----”的项目。

但外观和感觉不好,可以选择此项目。

我理想的方法是这样的:

那么如何做得更好?

任何建议将不胜感激!

I am trying to create a dropdown that can display both past state and possible state for a customer.

But I want to make add a separator between past and possible state.

Actually to do that I add an item like "-----" on the dataprovider.

But the look and feel is not good and this item may be selected.

My ideal approach is something like that:

So how to do better?

Any suggestions would be appreciated!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

红衣飘飘貌似仙 2025-01-04 06:04:16

我能想到的唯一方法是为 DropDownList 创建自定义外观。

我从未为该组件设计过皮肤,所以我无法向您提供更多详细信息,但如果您使用 Flash Builder,则为组件创建新皮肤非常容易:只需单击“”右侧的带有画笔和齿轮的图标即可皮肤”选择器并选择创建皮肤。然后,您可以自定义有关组件外观的所有内容。

The only way I can think of is to create a custom skin for the DropDownList.

I have never skinned that component so I can not give you more details but if you are using Flash Builder, it is very easy to create new skins for a component: Just click the icon with a brush and a gear to the right of the "Skin" selector and choose Create Skin. Then, you can customize everything about how the component looks.

倦话 2025-01-04 06:04:16

我会使用自定义 ItemRenderer。在最后一个项目上,您可以隐藏该线。但是,使用此代码,您将收到一条数据绑定警告,表明所有者不可绑定。

<s:itemRenderer>
    <fx:Component>
        <s:ItemRenderer width="100%" height="100%" 
                        autoDrawBackground="true">
            <fx:Script>
                <![CDATA[
                    import spark.components.supportClasses.ListBase;
                ]]>
            </fx:Script>
            <s:states>
                <s:State name="normal"/>
                <s:State name="down"/>
                <s:State name="hovered"/>
                <s:State name="selected"/>
                <s:State name="dragging"/>
                <s:State name="normalAndShowCaret"/>
                <s:State name="hoveredAndShowCaret"/>
                <s:State name="selectedAndShowCaret"/>
            </s:states>


            <s:Line width="100%" top="2" visible="{itemIndex==outerDocument.lengthOfFirstItems-1}">
                <s:stroke>
                    <s:SolidColorStroke weight="1" caps="square"/>
                </s:stroke>
            </s:Line>

            <s:Group top="8" left="2" right="2" bottom="2" width="100%" height="100%">
                <s:Label id="labelDisplay" verticalCenter="1" horizontalCenter="0" />
            </s:Group>
        </s:ItemRenderer>
    </fx:Component>
</s:itemRenderer>

在文档中创建一个名为 lengthOfFirstItems 的 int 类型变量。我假设你有两个数组?一个用于顶部项目,一个用于底部项目?如果是这样,则将第二个数组添加到第一个数组(或使用所有数组创建第三个数组)。在加入数组之前,将 lengthOfFirstItems 设置为第一组项目的长度。因此,使用图像作为示例,长度将为 2,因为有两个项目,您的行,然后是其余项目。

// position of end of first array. must be public to be accessible by outerDocument
public var lengthOfFirstItems:int = -1;

// get length of first array
lengthOfFirstItems = firstArray.length;

在本示例中,该线将在第一个项目数组的最后一行中可见。您可能需要调整代码,因为其中一部分是伪代码。

I would use a custom ItemRenderer. On the last item you could hide the line. However with this code you'll receive a data binding warning that the owner is not bindable.

<s:itemRenderer>
    <fx:Component>
        <s:ItemRenderer width="100%" height="100%" 
                        autoDrawBackground="true">
            <fx:Script>
                <![CDATA[
                    import spark.components.supportClasses.ListBase;
                ]]>
            </fx:Script>
            <s:states>
                <s:State name="normal"/>
                <s:State name="down"/>
                <s:State name="hovered"/>
                <s:State name="selected"/>
                <s:State name="dragging"/>
                <s:State name="normalAndShowCaret"/>
                <s:State name="hoveredAndShowCaret"/>
                <s:State name="selectedAndShowCaret"/>
            </s:states>


            <s:Line width="100%" top="2" visible="{itemIndex==outerDocument.lengthOfFirstItems-1}">
                <s:stroke>
                    <s:SolidColorStroke weight="1" caps="square"/>
                </s:stroke>
            </s:Line>

            <s:Group top="8" left="2" right="2" bottom="2" width="100%" height="100%">
                <s:Label id="labelDisplay" verticalCenter="1" horizontalCenter="0" />
            </s:Group>
        </s:ItemRenderer>
    </fx:Component>
</s:itemRenderer>

In your document create a variable called lengthOfFirstItems of type int. I assume you have two arrays? One for the top items and one for the bottom? If so then add the second array to the first (or create a third with all of them). Before joining your arrays set lengthOfFirstItems to the length of the first set of items. So using the image an example that length would be 2 since there are two items, your line, then the rest of the items.

// position of end of first array. must be public to be accessible by outerDocument
public var lengthOfFirstItems:int = -1;

// get length of first array
lengthOfFirstItems = firstArray.length;

With this example the line will be visible in the last row of the first array of items. You will probably have to adjust the code since part of it is pseudo code.

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