Maximum is set when the component is created and data isn't valid yet.
It will be later, so binding might pick it up, but binding to functions
could cause the value change to be missed.

 

________________________________

From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of zyzzx00_99
Sent: Thursday, July 24, 2008 6:32 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] numericStepper as an itemRenderer

 

Hey all. I have a numeric stepper and would like to set the max value
from another data.field. Certainly there are dozens of code-around
fixes for problems like these, but it seems like this should work:
(I'm copying and pasting code form a project I'm working on and with
the init function I'm replicating data in the fashion that it comes
back from a different team of developers)

[Bindable]
public var arrayCol : ArrayCollection = new ArrayCollection();

private function initHandler():void
{
var i : int;
var objArray : Array = new Array();

for(i=0; i < 10 ; i++ )
{
objArray.push( {QTY_TO_ISSUE:0,
QTY_ON_HAND:Math.round(Math.random()*50) } );
}

this.arrayCol = new ArrayCollection(objArray);
}

]]>
</mx:Script>

<mx:DataGrid id="test" dataProvider="{arrayCol}" height="50%">
<mx:columns>
<mx:DataGridColumn dataField="QTY_ON_HAND"
headerText="{ULang.Current.getString('On Hand')}" />
<mx:DataGridColumn dataField="QTY_TO_ISSUE" headerText="To Issue" 
sortable="false" editable="true" editorDataField="value"
rendererIsEditor="true" >
<mx:itemRenderer>
<mx:Component>
<mx:NumericStepper maximum="{ getMaxValue(data) }" minimum="0">
<mx:Script>
<![CDATA[

private function getMaxValue(obj:Object=null):Number
{
if(data)
return data['QTY_ON_HAND'];

return 0;
}

]]>
</mx:Script>
</mx:NumericStepper>
</mx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>
</mx:columns>
</mx:DataGrid>

it looks like 'data' isn't defined, or some such thing, but an inline
if statement to check if data exists doesn't seem to help. Any ideas?

 

Reply via email to