在 AdvancedDataGridRendererProvider 渲染时设置 AdvancedDataGrid 的行高

发布于 2024-11-06 17:45:14 字数 3535 浏览 6 评论 0原文

Flex Guys,

无法使用自定义 AdvancedDataGridRendererProvider 数据网格渲染器设置 AdvancedDataGrid 中的行高。

Snapcode如下所示

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

请让我知道..我应该如何处理它..

我尝试使用下面的代码

为您的DataGrid设置variableRowHeight=true 然后,在 rednrerer 中在运行时调整测量高度 但我不应该以百分比设置measuredHeight。

提前致谢。 java

我对其进行了重新设计,工作代码如下所示,代码 ADG 和渲染器也如下

<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();
    }

]]>

Flex Guys,

Not 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();
    }

]]>

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

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

发布评论

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

评论(1

当爱已成负担 2024-11-13 17:45:14

您尚未在 ADG 中设置variableRowHeight=true。如果您不希望它可变,您也可以只使用 rowHeight=Number 。从那里开始,您的项目渲染器需要具有特定的高度(数字)而不是百分比,否则它将无法工作。

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.

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