【问题标题】:Datagrid with RadioButtonGroup itemrenderer带有 RadioButtonGroup itemrenderer 的 Datagrid
【发布时间】:2010-11-18 23:49:15
【问题描述】:

我不知道该怎么做,现在尝试了几件事,所以我会问。下面显示了我想要的。我只是不知道如何让它工作。

我的 AC 有几个问题和相关答案。这些必须显示在 DG 中,其想法是 DG 的行和列绑定到 AC。例如,如果问题 1 的答案是“是”,则“是”按钮必须为真,而其他两个都必须为假(如在正常的单选按钮组行为中)。但是当我通过单击更改按钮时,AC 的操作数据字段应相应更改。我这里够清楚了吗?

动态问卷调查。非常感谢任何帮助。

<?xml version = "1.0"?>
<mx:Application xmlns:mx = "http://www.adobe.com/2006/mxml">
    <mx:Script>
        <![CDATA[
            import mx.collections.ArrayCollection;

            [Bindable]
            public var questions : ArrayCollection = new ArrayCollection([
                { question: 'Question 1', anwer: 'Yes' },
                { question: 'Question 2', anwer: 'No' },
                { question: 'Question 3', anwer: 'Unknown' }, ]);
        ]]>
    </mx:Script>

    <mx:Panel title = "Questionaire example" height = "100%" width = "100%" paddingTop = "10"
              paddingLeft = "10" paddingRight = "10">

        <mx:DataGrid id = "dg" width = "100%" height = "100%" dataProvider = "{questions}">
            <mx:columns>
                <mx:DataGridColumn dataField = "question" headerText = "Questions"/>
                <mx:DataGridColumn width = "80" textAlign = "center" editable = "false"
                                   headerText = "Yes">
                    <mx:itemRenderer>
                        <mx:Component>
                            <mx:HBox horizontalAlign = "center" verticalAlign = "middle">
                                <mx:RadioButton/>
                            </mx:HBox>
                        </mx:Component>
                    </mx:itemRenderer>
                </mx:DataGridColumn>
                <mx:DataGridColumn width = "80" textAlign = "center" editable = "false"
                                   headerText = "No">
                    <mx:itemRenderer>
                        <mx:Component>
                            <mx:HBox horizontalAlign = "center" verticalAlign = "middle">
                                <mx:RadioButton/>
                            </mx:HBox>
                        </mx:Component>
                    </mx:itemRenderer>
                </mx:DataGridColumn>
                <mx:DataGridColumn width = "80" textAlign = "center" editable = "false"
                                   headerText = "Unknown">
                    <mx:itemRenderer>
                        <mx:Component>
                            <mx:HBox horizontalAlign = "center" verticalAlign = "middle">
                                <mx:RadioButton/>
                            </mx:HBox>
                        </mx:Component>
                    </mx:itemRenderer>
                </mx:DataGridColumn>
            </mx:columns>
        </mx:DataGrid>


    </mx:Panel>
</mx:Application>

【问题讨论】:

    标签: apache-flex datagrid itemrenderer


    【解决方案1】:

    当您谈到“操作”数据字段时,不确定您指的是什么:

    '但是当我通过单击更改按钮时,AC 的操作数据字段应相应更改。'

    当为问题 1 单击“是”时,您希望发生什么?

    在 itemrenderers 中设置数据会覆盖 set data 函数,当渲染器初始化时,该行的所有数据都将出现在值对象中

    【讨论】:

      【解决方案2】:

      ToggleButtonBarRadioButton 更易于使用,而且它在功能上是相同的组件(设置 selectedIndex ——一次只能选择一个)。

      不要将每个单选按钮放在自己的列中,而是将 ToggleButtonBar 放在一列中。

      【讨论】:

        猜你喜欢
        • 2015-05-14
        • 2012-03-10
        • 1970-01-01
        • 2011-11-03
        • 2012-01-21
        • 1970-01-01
        • 2011-10-14
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多