0

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

我有一个有几个问题和相关答案的交流电。这些必须显示在 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>
4

2 回答 2

0

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

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

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

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

于 2009-08-19T22:00:02.040 回答
0

theToggleButtonBar比 a 更容易使用,RadioButton并且它在功能上是相同的组件(设置 selectedIndex - 一次只能选择一个)。

不要将每个单选按钮放在自己的列中,只需将 ToggleButtonBar 放在一列中即可。

于 2009-08-12T15:53:47.100 回答