ItemRenderer height (and height changes) is not reflected in the AdvancedDataGrid row

I have an AdvancedDataGrid with a variable row height equal to true. I wrote a cutsom rendering tool based on the spark component of a DataGroup. Each row in the grid has several objects to display, the position and width of the ent element are based on the data of the object itself.

I have a custom layout written for a DataGroup that measures and positions each object based on its data. Each object in each line can either truncate or not truncate its label. When the labels are not truncated, I calculate the actual width of the object and check its size manually (to make the label have the correct width and layout of all its text lines, by itself) in the DataGroup layout measurement method to accurately measure the datagroup.

Layouts, measurement, calibration, display, etc. work correctly. Entities report the correct height that they need when they don’t truncate the labels, the datagroup reports the correct size that it needs to draw the whole entity of its rows (all of the measurement methods, as they should be in the UIComponent life cycle).

When inside the AdvancedDataGrid itself, the rows are of the wrong size. Most lines do not require multiple lines and are displayed just fine. Those that require multiple lines have a large row height, but are not so large that in most cases the entire text can be placed. The DataGroup for this row (and its itemRenderers) is truncated. In addition, when scrolling the grid, each line scrolled on the screen is the default line height of the text, regardless of the data. In any case, resizing AdvancedDataGrid (without changing its columns, but the grid itself) forces all rows to snap to the desired height. Scrolling again creates lines with a fixed number of lines.

, - ( ). , ( ) DataGroup. , ArrayCollections, AdvandedDataGrid, ArrayCollections , DataGroup, DataGroup .

, AdvancedDataGrid , ADG, .

- AdvancedDataGrid ItemRenderers, AdvandedDataGrid ?

, , , , , , - .

, , , , , . , , , , . , , . :

<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 . , , , . , , :

            <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.

.

, , ( ):

, , enter image description here

, , - enter image description here

, , , , , . enter image description here

+1
2

meausre DataGroup .

, , , , DataGroup, . validateSize() ( ). , , . .

DataGroup, , AdvancedDataGrid .

, , .

, - ScrollingLabelItemRenderer , , , , , , .

ScrollingLabelItemRenderer, , updateDisplayList...

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

, MX AdvancedDataGrid , . , . grid-, , .

Spark AdvancedDataGrid, Spark DataGrid .

0

Source: https://habr.com/ru/post/1706546/


All Articles