Flex,如何将 dataGrid dataField 中的数据与字符串值进行比较?
这个问题看似简单,但却给我带来了麻烦。我有一个带有两个数据字段的数据网格:peerID、名称。当新用户加入群组(我正在创建聊天)时,网格中的信息会动态更新。我需要有关断开连接后从网格中删除的用户的信息。
因此,在“NetGroup.Neighbor.Disconnect”:事件中,我想将“event.info.peerID”值与网格中的所有peerID值进行比较,并删除有关断开连接的用户的信息。
我正在尝试使用下一个构造:
for (var i:uint, len:uint = txtDataArray.length; i < len; i++)
{
if (txtDataArray.source[i] == event.info.peerID)
{
txtDataArray.removeItemAt(i);
break;
}
}
<s:DataGrid id="txtData" x="11" y="59" width="238" height="164" alternatingRowColors="[ #67676767, #555555]" borderVisible="true" chromeColor="#555555" color="#CCCCCC" contentBackgroundColor="#555555" dataProvider="{callerns}" fontWeight="bold" requestedRowCount="4" rollOverColor="#08700D" selectionColor="#08700D" symbolColor="#CCCCCC">
<s:columns>
<s:ArrayList id="txtDataArray">
<s:GridColumn dataField="name" headerText="USERS ONLINE"></s:GridColumn>
<s:GridColumn dataField="peerID" headerText="USER ID" visible="true"></s:GridColumn>
</s:ArrayList>
</s:columns>
</s:DataGrid>
但它根本不起作用!
我注意到构造 txtDataArray.source[i] (或 txtDataArray.getItemAt(i) )返回 [object GridColumn] 而不是值。所以,我有两个问题: 1)如何获取精确单元格的值? 2)用户断开连接后如何组织信息删除?
先感谢您!
The question seems to be simple, however it create problems for me. I have a dataGrid with two dataFields: peerID, name. The information in a grid updated dynamically when new user joined the group (I'm creating a chat). I need that information about user deleted from a grid after it's disconnect.
So, on "NetGroup.Neighbor.Disconnect": event i want to compare "event.info.peerID" value with all peerID values in a grid and delete info about disconnected user.
I'm trying to use next construction:
for (var i:uint, len:uint = txtDataArray.length; i < len; i++)
{
if (txtDataArray.source[i] == event.info.peerID)
{
txtDataArray.removeItemAt(i);
break;
}
}
<s:DataGrid id="txtData" x="11" y="59" width="238" height="164" alternatingRowColors="[ #67676767, #555555]" borderVisible="true" chromeColor="#555555" color="#CCCCCC" contentBackgroundColor="#555555" dataProvider="{callerns}" fontWeight="bold" requestedRowCount="4" rollOverColor="#08700D" selectionColor="#08700D" symbolColor="#CCCCCC">
<s:columns>
<s:ArrayList id="txtDataArray">
<s:GridColumn dataField="name" headerText="USERS ONLINE"></s:GridColumn>
<s:GridColumn dataField="peerID" headerText="USER ID" visible="true"></s:GridColumn>
</s:ArrayList>
</s:columns>
</s:DataGrid>
But it doesn't work at all!
I'v noticed that construction txtDataArray.source[i] (or txtDataArray.getItemAt(i) ) returned [object GridColumn] insead of value. So, I have two questions:
1) How to get the value of exact cell?
2) How to organized info delete after user disconnect?
Thank you in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为什么使用
txtDataArray.source[i]
?您可以这样写:
或者如果您愿意,可以使用
foreach
。顺便说一句,我喜欢你的数据网格的风格。
Why are you using
txtDataArray.source[i]
?You can write like this:
or use
for each
if you want.By the way, I like your datagrid's style.