0
我有一個Flex 4中的數據網格,其中一個NumericStepper作爲數值的編輯器。我可以爲NumericStepper設置預定義的最大值和最小值,但是我需要能夠爲DataGrid中的每一行設置不同的限制。我怎樣才能做到這一點?DataGrid中的NumericStepper的行特定限制
這是DataGrid的代碼:
<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="0" maximum="50" stepSize="1" width="35" height="20"></mx:NumericStepper>
</fx:Component>
</mx:itemEditor>
</mx:DataGridColumn>
</mx:columns>
</mx:DataGrid>
編輯: 基於Flextras答案,我已經改變了NumericStepper行
<mx:NumericStepper minimum="{data.minNo}" maximum="{data.maxNo}" stepSize="1" width="35" height="20"></mx:NumericStepper>
,但現在我得到的StackOverflowError當我單擊單元格以更改值。我在這裏發佈了一個新問題:StackOverflowError on DataGrid row specific limits in a NumericStepper
謝謝。對不起,我不明白,我沒有試圖根據行的位置,但正如你所說,在行數據。我還將data ['min']更改爲data.min,因爲我得到了以下警告:「使用方括號運算符時,數據綁定將無法檢測到更改。對於Array,請使用ArrayCollection.getItemAt()。」但是,現在當單擊以更改步進器中的值時,出現StackOverflow錯誤(!)。有什麼建議麼? – Lizzan 2010-10-01 05:48:56
不是使用綁定,而是監聽itemEditor的dataChange事件,並在其中設置NumericStepper的最小值和最大值。 – JeffryHouser 2010-10-01 12:37:20
謝謝!我接受了我在另一個問題中提出的建議,但總是有很好的選擇! =) – Lizzan 2010-10-04 06:08:23