AdvancedDataGrid 水平/垂直滚动条问题。 (弹性)

发布于 2024-09-11 03:38:56 字数 336 浏览 13 评论 0原文

所以,我有一个 AdvancedDataGrid 需要位于 Canvas 内。我的问题是,当你做这样的事情时,你会得到两组滚动条。此外,当您从右向左滚动时,AdvancedDataGrid 的水平滚动条会改变大小,并且不会让您一直滚动到右侧,这看起来很奇怪。

我已经关闭了 AdvancedDataGrid 的水平滚动功能,只让 Canvas 处理它。然而,当我这样做时,列不允许调整自身大小。啊。

我当前的“最佳”解决方案是让 AdvancedDataGrid 处理垂直滚动,让 Canvas 处理水平滚动,但这看起来很疯狂,更不用说我遇到了上面提到的问题,我无法再调整列的大小。

非常感谢任何帮助! 谢谢!

So, I have an AdvancedDataGrid that needs to live inside a Canvas. My problem is that when you do something like this you get two sets of scroll bars. Also, the horizontal scroll bar for the AdvancedDataGrid changes size as you scroll right to left and will not let you scroll ALL the way to the right, which seems odd.

I've turned horizontal scrolling off on the AdvancedDataGrid and let only the Canvas handle it. When I do that, however, the columns don't allow themselves to be resizable. Ugh.

My current "best" solution is to have the AdvancedDataGrid handle the vertical scrolling and the Canvas handle the horizontal scrolling, but this just seems insane, not to mention I get the problem I mentioned above where I can no longer resize columns.

Any help is greatly appreciated!
Thanks!

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

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

发布评论

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

评论(2

如梦初醒的夏天 2024-09-18 03:38:56

AdvancedDataGrid 的水平滚动有些特殊,因为它根据可见列的宽度调整其水平滚动滑块的大小。实际上,您可以将拇指拖动到末尾,但这可能需要尝试几次。 (我知道,我知道...)

请记住,在 AdvancedDataGrid 中,在视口之外实际上没有渲染任何内容,因此任何大小调整都只是一个有根据的(好吧,有点有根据的)猜测。 Adobe 这样做是为了避免巨大的网格陷入困境(想象一下每次调整窗口大小时在 15,000 个单元格的 itemRenderer 上运行测量方法)。

我的建议是关闭 Canvas 中的垂直和水平滚动策略,并允许在 ADG 中处理滚动。它很丑陋,但它胜过其他选择。无论如何,ADG 都是一个笨重、脾气暴躁的装置,这可能就是 Adob​​e 将其开源的原因。我已经发誓很多次我再也不会使用它了。我只能在下次需要它的功能时才遵守这个誓言。大约每周一次。

The AdvancedDataGrid's horizontal scrolling is somewhat peculiar, in that it sizes its horizontal scroll thumb based on the width of the visible columns. You actually can drag the thumb to the end, but it might take a couple of tries. (I know, I know ...)

Remember that in the AdvancedDataGrid there is nothing actually rendered outside the viewport, so any sizing is just an educated (well, somewhat educated) guess. Adobe does this so that huge grids don't bog down to a crawl (imagine running measure methods on 15,000 cells' itemRenderers every time you resized the window).

My advice is to turn off both vertical and horizontal scroll policies in the Canvas and allow the scrolling to be handled in the ADG. It's ugly, but it beats the alternative. The ADG is a cumbersome, cantankerous contraption anyway, which may be why Adobe has open-sourced it. I have sworn many times I would never use it again. I've been able to keep that vow only until the next time I needed its features. Which is about every week.

热风软妹 2024-09-18 03:38:56

AdvancedDataGrid 是画布中唯一的东西吗?

我会将 AdvancedDataGrid 的大小调整为完整的高度和宽度,并让 Canvas 处理滚动。

在画布中,重写 updateDisplayList 方法并执行如下操作:

protected function updateDisplayList(unscaledWidth: Number, unscaledHeight: Number):void{
 super.updateDisplayList, unscaledHeight);
 this.myAdvancedDataGrid.setActualSize(this.myAdvancedDataGrid.measuredHeight, this.myAdvancedDataGrid.measuredWidth );
}

这样 AdvancedDataGrid 应该没有滚动条。但是,如果它延伸到很下方或太右边,滚动条将出现在画布中。

阅读Flex 坐标系可能会对您有所帮助。 AdvancedDataGrid 是您的“内容”,而 Canvas 是您的本地内容。


我正在添加完整的运行代码示例来演示我的建议。

这是里面有 AdvancedDataGrid 的画布组件: com.flextras.stackOverflow.CanvasWithGrid

<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:fx="http://ns.adobe.com/mxml/2009" 
           xmlns:s="library://ns.adobe.com/flex/spark" 
           xmlns:mx="library://ns.adobe.com/flex/mx" width="400" height="300">
    <fx:Declarations>
        <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>

    <fx:Script>
        <![CDATA[
            import mx.collections.ArrayCollection;

            override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void{
                super.updateDisplayList(unscaledWidth, unscaledHeight);
                this.myADG.setActualSize(this.myADG.measuredWidth, this.myADG.measuredWidth );
            }

            [Bindable]
            private var dpFlat:ArrayCollection = new ArrayCollection([
                {Region:"Southwest", Territory:"Arizona", 
                    Territory_Rep:"Barbara Jennings", Actual:38865, Estimate:40000}, 
                {Region:"Southwest", Territory:"Arizona", 
                    Territory_Rep:"Dana Binn", Actual:29885, Estimate:30000},  
                {Region:"Southwest", Territory:"Central California", 
                    Territory_Rep:"Joe Smith", Actual:29134, Estimate:30000},  
                {Region:"Southwest", Territory:"Nevada", 
                    Territory_Rep:"Bethany Pittman", Actual:52888, Estimate:45000},  
                {Region:"Southwest", Territory:"Northern California", 
                    Territory_Rep:"Lauren Ipsum", Actual:38805, Estimate:40000}, 
                {Region:"Southwest", Territory:"Northern California", 
                    Territory_Rep:"T.R. Smith", Actual:55498, Estimate:40000},  
                {Region:"Southwest", Territory:"Southern California", 
                    Territory_Rep:"Alice Treu", Actual:44985, Estimate:45000}, 
                {Region:"Southwest", Territory:"Southern California", 
                    Territory_Rep:"Jane Grove", Actual:44913, Estimate:45000}
            ]);

        ]]>
    </fx:Script>

    <mx:AdvancedDataGrid id="myADG" 

                         initialize="gc.refresh();"> <!--  width="100%" height="100%"  -->       
        <mx:dataProvider>
            <mx:GroupingCollection id="gc" source="{dpFlat}">
                <mx:grouping>
                    <mx:Grouping>
                        <mx:GroupingField name="Region"/>
                        <mx:GroupingField name="Territory"/>
                    </mx:Grouping>
                </mx:grouping>
            </mx:GroupingCollection>
        </mx:dataProvider>        

        <mx:columns>
            <mx:AdvancedDataGridColumn dataField="Region"/>
            <mx:AdvancedDataGridColumn dataField="Territory"/>
            <mx:AdvancedDataGridColumn dataField="Territory_Rep"
                                       headerText="Territory Rep"/>
            <mx:AdvancedDataGridColumn dataField="Actual"/>
            <mx:AdvancedDataGridColumn dataField="Estimate"/>
        </mx:columns>
    </mx:AdvancedDataGrid>

</mx:Canvas>

这是主应用程序文件:

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
               xmlns:s="library://ns.adobe.com/flex/spark" 
               xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" xmlns:stackOverflow="com.flextras.stackOverflow.*">
    <fx:Declarations>
        <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>

    <stackOverflow:CanvasWithGrid width="200" height="200" />


</s:Application>

Is the AdvancedDataGrid the only thing in your canvas?

I would size the AdvancedDataGrid to it's full height and width and let the Canvas handle scrolling.

In the canvas, override the updateDisplayList method and do something like this:

protected function updateDisplayList(unscaledWidth: Number, unscaledHeight: Number):void{
 super.updateDisplayList, unscaledHeight);
 this.myAdvancedDataGrid.setActualSize(this.myAdvancedDataGrid.measuredHeight, this.myAdvancedDataGrid.measuredWidth );
}

This way the AdvancedDataGrid should have no scroll bars. However, if it stretches to far down, or too far right the scroll bars will appear in the canvas.

You might benefit from reading up on the Flex Coordinate System. The AdvancedDataGrid is your "Content" while the Canvas would be your local.


I'm adding a full running code sample to demo my suggestion.

This is the canvas component with an AdvancedDataGrid inside it: com.flextras.stackOverflow.CanvasWithGrid

<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:fx="http://ns.adobe.com/mxml/2009" 
           xmlns:s="library://ns.adobe.com/flex/spark" 
           xmlns:mx="library://ns.adobe.com/flex/mx" width="400" height="300">
    <fx:Declarations>
        <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>

    <fx:Script>
        <![CDATA[
            import mx.collections.ArrayCollection;

            override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void{
                super.updateDisplayList(unscaledWidth, unscaledHeight);
                this.myADG.setActualSize(this.myADG.measuredWidth, this.myADG.measuredWidth );
            }

            [Bindable]
            private var dpFlat:ArrayCollection = new ArrayCollection([
                {Region:"Southwest", Territory:"Arizona", 
                    Territory_Rep:"Barbara Jennings", Actual:38865, Estimate:40000}, 
                {Region:"Southwest", Territory:"Arizona", 
                    Territory_Rep:"Dana Binn", Actual:29885, Estimate:30000},  
                {Region:"Southwest", Territory:"Central California", 
                    Territory_Rep:"Joe Smith", Actual:29134, Estimate:30000},  
                {Region:"Southwest", Territory:"Nevada", 
                    Territory_Rep:"Bethany Pittman", Actual:52888, Estimate:45000},  
                {Region:"Southwest", Territory:"Northern California", 
                    Territory_Rep:"Lauren Ipsum", Actual:38805, Estimate:40000}, 
                {Region:"Southwest", Territory:"Northern California", 
                    Territory_Rep:"T.R. Smith", Actual:55498, Estimate:40000},  
                {Region:"Southwest", Territory:"Southern California", 
                    Territory_Rep:"Alice Treu", Actual:44985, Estimate:45000}, 
                {Region:"Southwest", Territory:"Southern California", 
                    Territory_Rep:"Jane Grove", Actual:44913, Estimate:45000}
            ]);

        ]]>
    </fx:Script>

    <mx:AdvancedDataGrid id="myADG" 

                         initialize="gc.refresh();"> <!--  width="100%" height="100%"  -->       
        <mx:dataProvider>
            <mx:GroupingCollection id="gc" source="{dpFlat}">
                <mx:grouping>
                    <mx:Grouping>
                        <mx:GroupingField name="Region"/>
                        <mx:GroupingField name="Territory"/>
                    </mx:Grouping>
                </mx:grouping>
            </mx:GroupingCollection>
        </mx:dataProvider>        

        <mx:columns>
            <mx:AdvancedDataGridColumn dataField="Region"/>
            <mx:AdvancedDataGridColumn dataField="Territory"/>
            <mx:AdvancedDataGridColumn dataField="Territory_Rep"
                                       headerText="Territory Rep"/>
            <mx:AdvancedDataGridColumn dataField="Actual"/>
            <mx:AdvancedDataGridColumn dataField="Estimate"/>
        </mx:columns>
    </mx:AdvancedDataGrid>

</mx:Canvas>

This is the main application file:

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
               xmlns:s="library://ns.adobe.com/flex/spark" 
               xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" xmlns:stackOverflow="com.flextras.stackOverflow.*">
    <fx:Declarations>
        <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>

    <stackOverflow:CanvasWithGrid width="200" height="200" />


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