绑定数据网格中的数据
我有一个由两个数据网格和一个按钮组成的表单。 Datagrid 1“myStaticDataGrid”具有我添加的值供用户选择。我希望按钮的单击事件将 myStaticDataGrid 的当前选择发送到第二个数据网格“myDataGrid”。如果我使用文本框和数据网格,我就能够完成此任务,但我无法找到正确的语法来从 myStaticDataGrid 获取选择数据。
这是我使用两种数据网格方法的尝试:
<s:Form id="myForm">
//The values from this grid are determined once the button is clicked.
<s:FormItem id="myDataGrid">
<s:DataGrid id="bdgFormData">
<s:typicalItem>
<s:DataItem formData="Description" xmlData="Value"/>
</s:typicalItem>
<s:ArrayCollection id="values"> </s:ArrayCollection>
</s:DataGrid>
</s:FormItem>
//The values from this grid are determined at runtime.
<s:FormItem id="myStaticDataGrid">
<s:DataGrid id="userSelects">
<s:typicalItem>
<s:DataItem selects="Typical Item" codes="0000"/>
</s:typicalItem>
<s:ArrayCollection id="selects">
<s:DataItem selects="Y" codes="1"/>
<s:DataItem selects="N" codes="0"/>
</s:ArrayCollection>
</s:DataGrid>
</s:FormItem>
<s:FormItem label="Add Selects">
<s:Button label="Go" click="addData(event)"/>
</s:FormItem>
我的 AS 事件发送数据:
protected function addData(event:MouseEvent):void
{
//Put selected data at the top of the grid.
items.addItemAt(lstFormData.typicalItem,0)
}
我的问题是在哪里绑定网格数据?
这就是我将文本框数据发送到数据网格的方式:
<s:FormItem label="myDataUtil">
<s:Label text="Value"/>
<s:TextInput text="@{lstFormData.typicalItem.formData}"/>
</s:FormItem>
I have a form that consists of two data grids and a button. Datagrid 1, "myStaticDataGrid", has values I have added for the user to select from. I want the button's click event to send the current selection of myStaticDataGrid to the second datagrid, "myDataGrid". I have been able to accomplish this if I use a text box and a datagrid but I am having trouble finding the right syntax to grab the selection data from myStaticDataGrid.
This is my attempt using the two datagrid approach:
<s:Form id="myForm">
//The values from this grid are determined once the button is clicked.
<s:FormItem id="myDataGrid">
<s:DataGrid id="bdgFormData">
<s:typicalItem>
<s:DataItem formData="Description" xmlData="Value"/>
</s:typicalItem>
<s:ArrayCollection id="values"> </s:ArrayCollection>
</s:DataGrid>
</s:FormItem>
//The values from this grid are determined at runtime.
<s:FormItem id="myStaticDataGrid">
<s:DataGrid id="userSelects">
<s:typicalItem>
<s:DataItem selects="Typical Item" codes="0000"/>
</s:typicalItem>
<s:ArrayCollection id="selects">
<s:DataItem selects="Y" codes="1"/>
<s:DataItem selects="N" codes="0"/>
</s:ArrayCollection>
</s:DataGrid>
</s:FormItem>
<s:FormItem label="Add Selects">
<s:Button label="Go" click="addData(event)"/>
</s:FormItem>
My AS event to send the data:
protected function addData(event:MouseEvent):void
{
//Put selected data at the top of the grid.
items.addItemAt(lstFormData.typicalItem,0)
}
My question is where do I bind the grid data?
This is how I send the textbox data to a the datagrid:
<s:FormItem label="myDataUtil">
<s:Label text="Value"/>
<s:TextInput text="@{lstFormData.typicalItem.formData}"/>
</s:FormItem>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我为你准备了这个,不幸的是我这里只有 flex 3,所以你必须根据你需要的任何内容进行转换,但你应该了解它是如何工作的。
这是一个没有绑定数据的示例
I whipped this up for you unfortunately I only have flex 3 here so you will have to make conversions for whatever you need but you should get the idea of how it works.
Here is an example without binding data