handycam
08-07-2007, 07:23 PM
A while back, Chris posted an excellent solution for a numeric stepper item editor component. I have used this fine, but now it's not working.
I have a drag-n-drop grid. Items are dropped in, and on the click of a button, totals are added up. If I use the default data, it works. However, my stepper is not getting the min/max values, which are set in my XML file. The stepper appears when clicked, but using values not in my file (system defaults?) and the new value is not recognized.
The grid:
<mx:DataGrid id="choiceList" dataProvider="{_chosenItems}" width="100%" height="100%" wordWrap="true" variableRowHeight="true" editable="true" dropEnabled="true" dragEnabled="true" dragMoveEnabled="true" dragDrop="doDragDrop(event);">
<mx:columns>
<mx:DataGridColumn dataField="@qty" headerText="Quantity" width="70" itemEditor="myComponents.NSEditor" editorDataField="@qty"/>
<mx:DataGridColumn dataField="@units" headerText="" width="40"/>
<mx:DataGridColumn dataField="@ln2" headerText=""/>
</mx:columns>
</mx:DataGrid>
The stepper, which is myComponents.NSEditor:
<?xml version="1.0" encoding="utf-8"?>
<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" width="69" height="22">
<mx:Script>
<![CDATA[
public function get newTotal ():uint{
return step.value;
}
]]>
</mx:Script>
<mx:NumericStepper id="step" minimum="{data.@minQ}" maximum="{data.@maxQ}" stepSize=".25" value="{data.@qty}" />
</mx:VBox>
And each item in that Datagrid follows the format:
<item ln1="Onions, chopped" ln2="chopped onions" sn="onions" minQ=".25" maxQ=".5" qty=".5" units="cups" />
I have a drag-n-drop grid. Items are dropped in, and on the click of a button, totals are added up. If I use the default data, it works. However, my stepper is not getting the min/max values, which are set in my XML file. The stepper appears when clicked, but using values not in my file (system defaults?) and the new value is not recognized.
The grid:
<mx:DataGrid id="choiceList" dataProvider="{_chosenItems}" width="100%" height="100%" wordWrap="true" variableRowHeight="true" editable="true" dropEnabled="true" dragEnabled="true" dragMoveEnabled="true" dragDrop="doDragDrop(event);">
<mx:columns>
<mx:DataGridColumn dataField="@qty" headerText="Quantity" width="70" itemEditor="myComponents.NSEditor" editorDataField="@qty"/>
<mx:DataGridColumn dataField="@units" headerText="" width="40"/>
<mx:DataGridColumn dataField="@ln2" headerText=""/>
</mx:columns>
</mx:DataGrid>
The stepper, which is myComponents.NSEditor:
<?xml version="1.0" encoding="utf-8"?>
<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" width="69" height="22">
<mx:Script>
<![CDATA[
public function get newTotal ():uint{
return step.value;
}
]]>
</mx:Script>
<mx:NumericStepper id="step" minimum="{data.@minQ}" maximum="{data.@maxQ}" stepSize=".25" value="{data.@qty}" />
</mx:VBox>
And each item in that Datagrid follows the format:
<item ln1="Onions, chopped" ln2="chopped onions" sn="onions" minQ=".25" maxQ=".5" qty=".5" units="cups" />