Flex 3:当用户单击按钮时,从数组集合中删除项目并将其反映在转发器中
|
我有一个具有以下结构的arrayCollection:
projectErrorsAC
0
project1number
project2number
position1number
position2number
project1name
project2name
student
1
...
AC定义如下:
[Bindable] private var projectErrorsAC:ArrayCollection = new ArrayCollection;
我正在中继器中使用此交流电来显示每个错误。显示每个错误后,我放置了一个“接受”和“拒绝”按钮。用户单击这些按钮中的任何一个后,我想调用一个函数,该函数可以消除交流电中的特定错误。这是我到目前为止的内容:
中继器:
<mx:Repeater id=\"projRP\" width=\"100%\" dataProvider=\"{projectErrorsAC}\">
<mx:HBox>
<mx:Text id=\"projmsg\" text=\"{projRP.currentItem.student} is working on the following projects on the same day: {projRP.currentItem.proj1name} and {projRP.currentItem.proj2name}.\" />
<mx:Text id=\"allow\" text=\"Allow\" color=\"#ff0000\" selectable=\"false\"
click=\"acceptProjConflict(projRP.currentItem);\"
mouseOver=\"parentApplication.switchCursor(true);\"
mouseOut=\"parentApplication.switchCursor(false);\" />
<mx:Text text=\" |\" />
<mx:Text id=\"decline\" text=\"Decline\" color=\"#ff0000\" selectable=\"false\" click=\"declineProjConflict(projRP.currentItem);\" mouseOver=\"parentApplication.switchCursor(true);\" mouseOut=\"parentApplication.switchCursor(false);\" />
</mx:HBox>
</mx:Repeater>
这是我在“点击”部分中调用的函数:
public function acceptProjConflict(conflict:Object):void
{
for (var i:int = 0; i < projectErrorsAC.length; i++)
{
if (projectErrorsAC.getItemAt(i) == conflict)
projectErrorsAC.removeItemAt(i);
}
}
由于某种原因,这是行不通的...
*编辑*
成功!
我必须创建一个模块放入中继器内-中继器现在如下所示:
<mx:Repeater id=\"projRP\" width=\"100%\" dataProvider=\"{projectErrorsAC}\">
<conflict:showErrors id=\"projErrors\" thisObject=\"{projRP.currentItem}\" isProject=\"true\"/>
</mx:Repeater>
我的模块如下所示:
<?xml version=\"1.0\" encoding=\"utf-8\"?>
<mx:Module xmlns:mx=\"http://www.adobe.com/2006/mxml\" layout=\"absolute\" creationComplete=\"init();\">
<mx:Script>
<![CDATA[
public var isProject:Boolean;
public var thisObject:Object;
[Bindable] public var displayString:String = new String;
private function init():void
{
if (isProject)
{
displayString = thisObject.student + \" is working on the following projects on the same day: \" + thisObject.proj1name + \" and \" + thisObject.proj2name + \".\";
}
}
]]>
</mx:Script>
<mx:Canvas width=\"750\">
<mx:HBox>
<mx:Text id=\"projmsg\" text=\"{displayString}\" />
<mx:Text id=\"allow\" text=\"Allow\" color=\"#ff0000\" selectable=\"false\" click=\"parentDocument.acceptProjConflict(thisObject)\" mouseOver=\"parentApplication.switchCursor(true);\" mouseOut=\"parentApplication.switchCursor(false);\" />
<mx:Text text=\" |\" />
<mx:Text id=\"decline\" text=\"Decline\" color=\"#ff0000\" selectable=\"false\" click=\"parentDocument.declineProjConflict(thisObject);\" mouseOver=\"parentApplication.switchCursor(true);\" mouseOut=\"parentApplication.switchCursor(false);\" />
</mx:HBox>
</mx:Canvas>
</mx:Module>
没有找到相关结果
已邀请:
3 个回复
凰葱崎济邯
讼乐
但是,是的,可以肯定地确定您的问题在于从未调用过您的处理程序。
绊伦欧
代替
拥有大量数据时,它将更快。