如何删除 AdvancedDataGrid 上的突出显示/选择

发布于 2024-09-07 21:20:28 字数 393 浏览 3 评论 0原文

page 描述了如何重写 DataGrid 标头的 drawHighlightIndicator/drawSelectionIndicators 方法,但 AdvancedDataGrid 在 mx_internal 中没有“headerClass”。相反,它有一个 headerRenderer。

如何在 Flex 3 中的 AdvancedDataGrid 上删除那些被破坏的突出显示?

This page describes how to override the drawHighlightIndicator/drawSelectionIndicators methods for the header of a DataGrid, but an AdvancedDataGrid does not have "headerClass" in mx_internal. It instead has an headerRenderer.

How can I remove those blasted highlights over an AdvancedDataGrid in Flex 3?

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

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

发布评论

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

评论(2

猫弦 2024-09-14 21:20:28

很抱歉发布不同的答案,但我没有足够的“点”对此做出直接评论。今天我遇到了完全相同的问题,发现这篇文章非常有帮助。

如果我错了,请纠正我,但我认为 mouseDownHandler 中缺少一行,这会阻止 AdvancedDataGrid 正确对数据进行排序(如果启用了数据排序):

override protected function mouseDownHandler(event:MouseEvent):void
{
    super.mouseDownHandler(event);

    var s:Sprite = Sprite(
        selectionLayer.getChildByName("headerSelection"));

    if(s) s.graphics.clear();
}

尽管它可能很有用。

Sorry to post a different answer but I don't have enough 'points' to make a direct comment on this. Today I had run into exact same issue and found this post very helpful.

Correct me if I'm wrong but I think one line is missing in the mouseDownHandler which prevents AdvancedDataGrid from properly sorting the data (if data sorting is enabled):

override protected function mouseDownHandler(event:MouseEvent):void
{
    super.mouseDownHandler(event);

    var s:Sprite = Sprite(
        selectionLayer.getChildByName("headerSelection"));

    if(s) s.graphics.clear();
}

Though it may be useful.

桃酥萝莉 2024-09-14 21:20:28

AdvancedDataGridBaseEx.as 中第 5468-5471 行中绘制的图形调用:

var g:Graphics = s.graphics;
g.clear();
g.beginFill(getStyle("rollOverColor")); //all I really wanted was to decrease the alpha here :(
g.drawRect(0, 0, w, h - 0.5);
g.endFill();

要摆脱此问题,您可以在扩展 AdvancedDataGrid 的类中执行此操作:

package
{
    import flash.display.Sprite;
    import flash.events.MouseEvent;

    import mx.controls.AdvancedDataGrid;

    public class AdvancedDataGridMinusHighlights extends AdvancedDataGrid
    {
        public function AdvancedDataGridMinusHighlights()
        {
            super();
        }

        override protected function mouseOverHandler(event:MouseEvent):void
        {
            super.mouseOverHandler(event);

            var s:Sprite = Sprite(
                selectionLayer.getChildByName("headerSelection"));

            if(s) s.graphics.clear();

        }

        override protected function mouseDownHandler(event:MouseEvent):void
        {
            super.mouseDownHandler(event);

            var s:Sprite = Sprite(
                selectionLayer.getChildByName("headerSelection"));

            if(s) s.graphics.clear();
        }

    }
}

尽管这是一个极其不优雅的解决方案,因为它所做的一切都清楚已经是什么绘制的。因为 AdvancedDataGridBaseEx 中的鼠标处理程序中有很多其他废话,所以您将无法轻松自定义标头的外观。

一个稍微优雅的(黑客)解决方案是将 AdvancedDataGridBaseEx 的完整源代码复制到 mx.controls 包中(我相信你们中的许多人都知道这种黑客,并且同样意识到其后果)。

The graphics calls that draw that are in AdvancedDataGridBaseEx.as from lines 5468-5471:

var g:Graphics = s.graphics;
g.clear();
g.beginFill(getStyle("rollOverColor")); //all I really wanted was to decrease the alpha here :(
g.drawRect(0, 0, w, h - 0.5);
g.endFill();

To get rid of this you can do this in an class that extends AdvancedDataGrid:

package
{
    import flash.display.Sprite;
    import flash.events.MouseEvent;

    import mx.controls.AdvancedDataGrid;

    public class AdvancedDataGridMinusHighlights extends AdvancedDataGrid
    {
        public function AdvancedDataGridMinusHighlights()
        {
            super();
        }

        override protected function mouseOverHandler(event:MouseEvent):void
        {
            super.mouseOverHandler(event);

            var s:Sprite = Sprite(
                selectionLayer.getChildByName("headerSelection"));

            if(s) s.graphics.clear();

        }

        override protected function mouseDownHandler(event:MouseEvent):void
        {
            super.mouseDownHandler(event);

            var s:Sprite = Sprite(
                selectionLayer.getChildByName("headerSelection"));

            if(s) s.graphics.clear();
        }

    }
}

Although that is an extremely inelegant solution since all it does is clear what has already been drawn. Because there's so much other crap in the mouse handlers in AdvancedDataGridBaseEx you won't easily be able to customize the appearance of the header.

A slightly more elegant (hack) solution is to copy the full source of AdvancedDataGridBaseEx into the mx.controls package (a hack I'm sure many of you are aware of and equally aware of the consequences).

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