我有一个DataGrid,其中一个列的项目编辑器是NumericStepper。数字步进器应该从每一行的数据中获取其最大值和最小值。我的MXML如下所示:
<mx:DataGrid x="0" y="45" width="272" height="525" dataProvider="{dp}" variableRowHeight="true" editable="true" id="equipmentDG" verticalAlign="middle">
<mx:columns>
<mx:DataGridColumn headerText="Benämning" headerStyleName="gridheader" fontSize="12" width="128" dataField="name" editable="false"/>
<mx:DataGridColumn headerText="Antal" headerStyleName="gridheader" width="40" dataField="antal" editorDataField="value" editable="true">
<mx:itemEditor>
<fx:Component>
<mx:NumericStepper minimum="data.minNo" maximum="data.maxNo" stepSize="1" width="35" height="20"></mx:NumericStepper>
</fx:Component>
</mx:itemEditor>
</mx:DataGridColumn>
</mx:columns>
</mx:DataGrid>
问题是,当我运行应用程序并单击单元格时,在一系列其他错误之后,我得到了一个StackOverflowError。我得到的堆栈跟踪的最后几行(在它们开始重复之前)是:
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at mx.core::UIComponent/dispatchEvent()[E:\dev\4.x\frameworks\projects\framework\src\mx\core\UIComponent.as:12528]
at mx.controls::NumericStepper/set data()[E:\dev\4.x\frameworks\projects\framework\src\mx\controls\NumericStepper.as:629]
at mx.controls::NumericStepper/get data()[E:\dev\4.x\frameworks\projects\framework\src\mx\controls\NumericStepper.as:611]
at Function/()[/Users/lisbeth/Documents/Development/Typkatalog/DevelopmentBranch/src/planeringsverktyg/dialogs/TentInfo.mxml:267]
at Function/http://adobe.com/AS3/2006/builtin::apply()
at mx.binding::PropertyWatcher/updateProperty()[E:\dev\4.x\frameworks\projects\framework\src\mx\binding\PropertyWatcher.as:334]
at Function/http://adobe.com/AS3/2006/builtin::apply()
at mx.binding::Watcher/wrapUpdate()[E:\dev\4.x\frameworks\projects\framework\src\mx\binding\Watcher.as:192]
at mx.binding::PropertyWatcher/eventHandler()[E:\dev\4.x\frameworks\projects\framework\src\mx\binding\PropertyWatcher.as:375]
有什么想法吗?
1条答案
按热度按时间eoxn13cs1#
看起来,将
minimum
和maximum
绑定到数据会导致无限循环。但是,您不需要绑定来更改DataGrid中每一行的这两个值。覆盖data
的setter就可以实现这一点。请参见以下示例:如果字段
minNo
和maxNo
存在,则会进行显式检查,因为不知何故,setter经常被调用,并且大多数情况下value
不是预期的对象...