0

Is there a way to make a Flex 3 Datagrid show only the first node of an arrayCollection, instead of showing all of the arrayCollection's data?

    myDGArray = [
    {Name: "Judy", Talent: 'Pole-Dancing', Score: "40"},
    {Name: "Jane", Talent: 'Yodelling',    Score: "65"},
    {Name: "Jim",  Talent: 'Singing',      Score: "82"}
      ]

myAC:ArrayCollection = new ArrayCollection(myDGArray);

If I set the datagrid's dataProvider as myAC, then all of myAc's results will be listed in the dataGrid. How do I make it show only the first person's data, the not-so-hot Judy?

(The data in the myDGArray is actually from a database call. So, I'd like to return it all at once instead of making multiple server calls).

My goals is to have the datagrid load with the first person's data. And then have a comboBox control what data is shown in the dataGrid. So, if the user selects "Jim" in the comboBox, then Jim's data shows up in the dataGrid.

Any suggestions or advice?

Thank you.

-Laxmidi

4

3 回答 3

2

尝试这个

<mx:DataGrid dataProvider="myAC">
<mx:columns>
<mx:DataGridColumn headerText="Name" dataField="Name"/>
<mx:DataGridColumn headerText="Talent"/>
<mx:DataGridColumn headerText="Score"/>
</mx:columns>
</mx:DataGrid>
于 2010-11-24T12:07:28.037 回答
0

如果您总是只想在 DataGrid 中显示一条记录,那么您可能不需要使用(相当繁重的)DataGrid 组件。我会将数据提供者分配给组合框,并使用带有标签的 HBox 来获取详细信息。您可以将标签文本绑定到所选组合框项目的任何细节:

<mx:Label text="{'Talent: " + myCombo.selectedItem.Talent}"/>
于 2010-08-13T19:39:48.007 回答
0

尝试这个

<mx:DataGrid dataProvider="myAC">
<mx:columns>
<mx:DataGridColumn headerText="Name" dataField="Name"/>
<mx:DataGridColumn headerText="Talent"/>
<mx:DataGridColumn headerText="Score"/>
</mx:columns>
</mx:DataGrid>
于 2010-11-24T12:00:08.163 回答