本文介绍了的ItemRenderer hieght(和高度的变化)不会反映在的AdvancedDataGrid行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我有一个变量行高度设置为true的AdvancedDataGrid。我已经写了基于DataGroup的Spark组件在cutsom项目渲染器。网格中的每一行都有多个实体来显示,所述的entites都是基于该实体本身。

I have an AdvancedDataGrid with variable row height set to true.I have written a cutsom item renderer based on the DataGroup spark component. Each row in the grid has multiple entities to display, the x position and width of the entites are based on the data of the entity itself.

我对那个的措施和posistions每个实体基于其数据的DataGroup的编写自定义布局。每一行中的每个实体可以截断或不截断它的标签。当标签不会被截断,我计算出物体的实际宽度和验证其大小manualy(强制标签有正确的宽度和布局的文本行,并重新测量本身)的DataGroup的布局的测量方法中精确地测量DataGroup的本身。

I have a custom layout written for the DataGroup that measures and posistions each entity based on its data. Each entity in each row can either truncate or not truncate its label. When the labels are not truncated, I calculate the actual width of the object and validate its size manualy (to force the label to have the correct width and layout all its text lines and remeasure itself) within the DataGroup's Layout's measure method to accurately measure the datagroup itself.

布局,测量,大小,显示等全部正常工作。该实体的报告说,他们需要在不截断标签正确的高度,DataGroup的报告,它需要提请所有实体,其行的价值(一切从衡量方法,比如他们需要的UIComponent的生命周期下)正确的尺寸。

The layouts, measuring, sizing, display, etc all work correctly. The entitys report the correct height they need when not truncating the labels, the datagroup reports the correct size it needs to draw all of its row's worth of entities (all from measure methods like they need to under the UIComponent lifecycle).

当在AdvancedDataGrid本身里面,行不正确的大小。大多数的行不需要多行并显示就好了。那些需要多个行有较大的行高,但没有大到足以容纳在多数情况下整个文本。该DataGroup的该行(和它的itemRenderer)被剪切。此外,当滚动发车,滚动屏幕上的每一行是默认的1文本行的高度,数据irregardless。在任何情况下,调整在AdvancedDataGrid(未调整它的列,但网格本身)强制所有行捕捉到正确的所需的高度。滚动再产生incorreclty大小行。

When inside the AdvancedDataGrid itself, rows are not sized correctly. The majority of the rows do not require multiple lines and display just fine. Those that require multiple lines have larger row heights, but not large enough to accomodate the entire text in most cases. The DataGroup for that row (and its itemRenderers) are clipped. Furthermore, When scrolling the grid, every row scrolled onscreen is the default 1 text line height, irregardless of data. In any case, resizing the AdvancedDataGrid (not resizing its columns, but the grid itself) forces all rows to snap to the correct desired height. Scrolling again produces incorreclty sized rows.

此外,该行中的每个实体的布局由几个外部因素被确定 - 最通常是可见范围(沿水平方向)。改变这种可见光范围内将触发所有项目渲染器来调整自己(通过自定义布局类),以他们的新尺寸和重新对新DataGroup的布局。这实际上会触发一个自定义的层次结构解析器重建所有AdvandedDataGrid数据提供内部使用的ArrayCollections,所以ArrayCollections被派遣改变事件的每一行的DataGroup的反应是,这样的DataGroup本身是无效的大小和布局。

Additionally, the layout of each entity in the row is determined by several external factors - most commonly being visible range (along the horizontal). Changing this visible range will trigger all item renderers to resize themselves (through the custom layout class) to their new sizes and remeasuring the new DataGroup layout. This actually triggers a custom hierarchy parser which rebuilds all the ArrayCollections used inside the AdvandedDataGrid data provider, so ArrayCollections are dispatching change events that each row's DataGroup reacts to, so the DataGroup itself is invalidating its size and layout.

这些尺寸调整不会触发的AdvancedDataGrid重新测量其行高,我必须rezise助理总干事本身再次抓拍行正确的高度。

These resizes do not trigger the AdvancedDataGrid to remeasure its row heights, and I must rezise the ADG itself again to snap the rows to the correct height.

任何人都有在移动AdvancedDataGrid或动态的itemRenderer大小行的经验,必须强制进行AdvandedDataGrid重新布局其行?

Anyone have any experience with dynamically sized rows in an AdvancedDataGrid or ItemRenderers which must forcibly make the AdvandedDataGrid re-layout its rows?

不幸的是,我不能提供源$ C ​​$ C,因为有一个庞大的类进入这个号码,分层数据,卷起封闭的节点成多行,定制层次解析器,众多项目渲染器 - 这和它的一个政府合同。

Unfortunately, I cannot provide source code as there are a huge number of classes going into this, hierarchial data, rolling up closed nodes into multiple rows, custom hierarchy parsers, a multitude of item renderers - that and its a Government contract.

我也碰到了类似的问题,一个非常简单的项目渲染器,基本上会尊重一个最大高度,调整自身高​​达身高作为其自动换行的数据需要,然后创建滚动条,为自己的标签。同样,当创建了网格,然后改变了列宽的网格内不调整行高的项目渲染器调整到其新宽度的数据大小几乎correclty。只有在调整网格本身做项目渲染调整正确,创建滚动条和网格行高度是正确的。该人士为该项目渲染:

I have run into a similar issue with a much simpler item renderer, basically a label that will respect a max height, resize itself upto that height as its wordwrapping data will require, and then create scrollbars for itself. Again, the data sizes almost correclty when the grid is created, then changing the column width within the grid does not resize the row height as the item renderer adjusts to its new width. Only in resizing the grid itself do the item renderers resize correctly, create scroll bars, and the grids row heights are correct. The source for that item renderer:

<s:Scroller xmlns:fx="http://ns.adobe.com/mxml/2009"
            xmlns:s="library://ns.adobe.com/flex/spark"
            xmlns:mx="library://ns.adobe.com/flex/mx"
            implements="mx.controls.listClasses.IDropInListItemRenderer,mx.controls.listClasses.IListItemRenderer"
            horizontalScrollPolicy="off" width="100%">
    <fx:Script>
        <![CDATA[

            import mx.controls.listClasses.BaseListData;
            import mx.controls.listClasses.IDropInListItemRenderer;
            import mx.controls.listClasses.IListItemRenderer;
            import mx.events.ResizeEvent;


            private var _listData:BaseListData;
            private var _data:Object;

            private var _listOrData_c:Boolean = false;

            public function get listData():BaseListData
            {
                return _listData;
            }
            public function set listData(value:BaseListData):void
            {
                _listData = value;
                _listOrData_c = true;
                invalidateProperties();
            }

            public function get data():Object
            {
                return _data
            }
            public function set data(value:Object):void
            {
                _data = value;
                _listOrData_c = true;
                invalidateProperties();
            }

            override protected function commitProperties():void
            {
                if(_listOrData_c)
                {
                    _listOrData_c = false;
                    label.text = _listData.label;
                }

                super.commitProperties();
            }

        ]]>
    </fx:Script>
    <fx:Declarations>
        <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>
    <s:Group width="100%">
        <s:layout>
            <s:BasicLayout clipAndEnableScrolling="true" />
        </s:layout>
        <s:Label id="label" width="100%"/>
    </s:Group>
</s:Scroller>

扔到的AdvancedDataGrid并设置一些数据具有非常大的文本块。调整列的大小,然后调整网格本身,希望可以重现相同的结果。确保你的项目渲染器设置一个最大高度,如:

Throw it into a AdvancedDataGrid and set some data with very large text blocks. Resize columns, then resize the grid itself, hopefully you can reproduce the same results. Make sure you set a max height on the item renderers like:

            <mx:AdvancedDataGridColumn id="adgc1" headerText="Name" dataField="label">
                <mx:itemRenderer>
                    <fx:Component>
                        <newLayouts:ScrollingTextItemRenderer maxHeight="60" />
                    </fx:Component>
                </mx:itemRenderer>
            </mx:AdvancedDataGridColumn>

使用Flex 4.1。

Using Flex 4.1.

感谢您的帮助。

下面是截图,详细的项目渲染器,因为它应该发挥作用(因为我有固定的测量测量前强制验证标签在明确当前宽度):

Here are screenshots detailing the item renderer as it should function (as I have fixed the measuring to forcibly validate the label at the explicit current width before measuring):

非常宽列,没有滚动条,标签测量高度示于行高度

Very wide column, no scroll bars, the labels measured height is shown in the row height

小宽列,一些渲染砸中最大高度和创建滚动条,最后渲染器依然采用了标签的测量高度

Smaller width column, some renderers have hit max height and are creating scroll bars, the last renderer is still using the measured height of the label

小仍列,所有的最大高度被打和滚动条是present的所有标签,滚动条将选择该行使用,但允许滚动,因此所有文本是可见的时候。

Smaller still column, all max heights are hit and scrollers are present for all labels, scrollers will select the row when used but allow scrolling so all text is viewable.

推荐答案

经过一番仔细检查今天上午,为的DataGroup的meausre方法渲染器本身并没有correclty在第一项措施通过验证其子项的大小。

After much closer inspection this morning, the meausre method for the DataGroup renderers themselves was not correclty validating the size of its children upon first measure pass.

我需要这些项目中的标签有一个限制的宽度,以便他们会换行适当的,所以当我测量的DataGroup行我需要设置它的每一个孩子的宽度,然后测量了孩子。问题是validateSize()没有被正确验证的元件尺寸(标签没有被更新,并且在这一点上产生了新的文本行)。所有后续措施传球已经有了一个宽验证,以每个孩子因此测量它们又是正确的。因此,调整网格时,后续的措施调用工作。

I need the labels in those items to have a restricted width so they will wordwrap appropriately, so when I am measuring the DataGroup row I need to set the width of each of its children and then measure the child. The problem was validateSize() was not correctly validating the elements size (the label was not being updated and generating its new text lines at this point). All subsequent measure passes already had a width validated to each child so measuring them again was correct. So when resizing the grid, the subsequent measure calls worked.

我把强制验证中的DataGroup的测量方法,现在正在返回正确的高度,因此在AdvancedDataGrid是实际上可以correclty现在上浆其行每一个孩子。

I took to forcibly validating each child within the DataGroup's measure method and the correct heights are now being returned and as such the AdvancedDataGrid is acutally sizing its rows correclty now.

这可以是相当低效的,因为每个项目的每个生命周期通过验证两次了,但电网正在执行的期望。

This can be rather inefficient as each item is validated twice per lifecycle pass now, but the grid is performing as desired.

也许类似的东西会在与ScrollingLabelItemRenderer作为标签可能不会得到它的宽度进行验证时,它可以测量自身从而在第一时间设置其中的格接受并使用的行高了错误的测量大小。

Probably something similar going on with the ScrollingLabelItemRenderer as the label probably doesn't get its width validated when it measures itself the first time thus sets the wrong measured size which the grid accepts and uses as row height.

我有ScrollingLabelItemRenderer正常工作现在又说,我不得不强行施加宽度标签和测量的渲染器时,监守它是应用新宽度之前,测量时仍然使用其previous宽度和文本行进行验证在随后的updateDisplayList ...

I have the ScrollingLabelItemRenderer functioning correctly now again, I had to forcibly apply a width to the label and validate it when measuring the renderer becuase it was still using its previous width and text lines when measuring before applying a new width in the subsequent updateDisplayList ...

        override protected function measure():void
        {
            label.width = getExplicitOrMeasuredWidth() - verticalScrollBar.getExplicitOrMeasuredWidth();
            label.validateNow();
            super.measure();
        }

这篇关于的ItemRenderer hieght(和高度的变化)不会反映在的AdvancedDataGrid行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 14:29