开发者

Setting the AdvancedDataGrid's row height while AdvancedDataGridRendererProvider rendering

开发者 https://www.devze.com 2023-03-05 07:21 出处:网络
Flex Guys, No开发者_如何学Ct able to setting height of row in AdvancedDataGrid using custom AdvancedDataGridRendererProvider datagrid renderer.

Flex Guys,

No开发者_如何学Ct able to setting height of row in AdvancedDataGrid using custom AdvancedDataGridRendererProvider datagrid renderer.

Snapcode as here

<mx:AdvancedDataGrid id="docId" 
                                     visible="true"
                                     width="100%" height="100%"
                                     dataProvider="{data}" 
                                     horizontalScrollPolicy="on"
                                     verticalScrollPolicy="on"
                                     styleName="MyStyle"
                                     styleFunction="getRowColours" 
                                     headerStyleName="MyStyle2"
                                     >
                    <mx:columns>
                        <mx:AdvancedDataGridColumn id="Name" dataField="name" 
                                                   headerText="Name" /> 
                        <mx:AdvancedDataGridColumn id="Value" dataField="values" 
                                                   headerText="Value" 
                                                   editable="true" />
                    </mx:columns>
                    <mx:rendererProviders>
                        <mx:AdvancedDataGridRendererProvider  id="DocID2"
                                                              columnIndex="1" columnSpan="1"
                                                              renderer="{new ClassFactory(MyRenderer)}" />
                    </mx:rendererProviders>
                </mx:AdvancedDataGrid>

Please do let me know ..how should i handle it ..

I tried with below code

Set variableRowHeight=true for your DataGrid and then, inside your rednrerer adjust measuredHeight at run time But i should not set measuredHeight in percentage .

Thanks in advance. java

I reworked on it and working code as below code ADG and renderer too

<mx:AdvancedDataGrid id="adg" dataProvider="{input}" height="350" variableRowHeight="true" >
        <mx:columns>
            <mx:AdvancedDataGridColumn dataField="company" headerText="Company"/>
            <mx:AdvancedDataGridColumn dataField="product" headerText="Product"/>
        </mx:columns>
        <mx:rendererProviders>
            <mx:AdvancedDataGridRendererProvider  id="myDataGridRenderer"
                                                  columnIndex="1" columnSpan="1"
                                                  renderer="{new ClassFactory(DataGridRowTestRenderer)}" />
        </mx:rendererProviders>
    </mx:AdvancedDataGrid>

    import spark.components.Label;
    import spark.components.TextArea;

    private var label1:Label;
    private var textArea1:TextArea;
    private var index:int;

    override public function set data(object:Object):void {
        super.data = object;

        this.removeAllElements();

        label1 = new Label();
        label1.text = object.company;

        this.addElement(label1);

        var textArea:TextArea = new TextArea();
        //textArea.text = object.product;
        //textArea.heightInLines = 2;

        index = object.index as int;

        textArea.heightInLines = index+1;

        textArea.text = object.product;
        /* if((index%2) == 0){
            textArea.heightInLines = 2;
        }else{
            textArea.heightInLines = 4;
        } */
        this.addElement(textArea);
    }

    override public function validateDisplayList():void{
        super.validateDisplayList();
    }

]]>


You haven't set variableRowHeight=true in your ADG. You can also just use rowHeight=Number if you don't want it variable. From there, your item renderer needs to have a specific height (number) not a percentage or else it won't work.

0

精彩评论

暂无评论...
验证码 换一张
取 消