Iain, out of curiousity I put your renderer code into a file named
NumericStepperRenderer.mxml and it worked fine with the following sample
app.  There may be some problem in your datagrid declaration; a misnamed
column perhaps?

<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml";>

<mx:Script>

<![CDATA[

var dataArray: Array = [

   {label: "a", stepper: 1, fill:10},

   {label: "b", stepper: 2, fill: 20},

   {label: "c", stepper: 3, fill: 30}

];

]]>

</mx:Script>

<mx:DataGrid dataProvider="{dataArray}">

<mx:columns>

<mx:Array>

<mx:DataGridColumn columnName="label" headerText="Label"/>

<mx:DataGridColumn columnName="stepper" headerText="Stepper"
cellRenderer="NumericStepperRenderer"/>

</mx:Array>

</mx:columns>

</mx:DataGrid>

</mx:Application>


--- In [email protected], "digital_eyezed" <[EMAIL PROTECTED]>
wrote:
>
> Thanks,
>
> I tried this, but the numericStepper just stops stepping.
>
> Any other ideas?
>
> CHeers,
>
> Iain
>
> New Renderer code:
>
> <mx:HBox horizontalAlign="center" width="100%"
> xmlns:mx="http://www.macromedia.com/2003/mxml";>
> <mx:Script>
> <![CDATA[
> var labelData:Object;
> var val;
> var listOwner : MovieClip;
> var getCellIndex : Function;
> var getDataLabel : Function;
>
> function setValue(str:String, item:Object) {
> if (item == undefined){
> visible = false;
> return;
> }
> visible = true;
> var s = item;
> labelData = s;
> val = labelData.stepper;
> }
>
> function changeVal(){
> val = changed.value;
> listOwner.editField(getCellIndex().itemIndex, getDataLabel(), val);
> }
> ]]>
> </mx:Script>
> <mx:NumericStepper id="changed" value="{val}" change="changeVal()"
> maximum="{labelData.fill}"/>
> </mx:HBox>
>
> --- In [email protected], "Doug Lowder" douglowder@ wrote:
> >
> >
> > Hi Iain,
> >
> > You need to update the grid's data field in your change handler. Try
> > the following:
> >
> > var listOwner : MovieClip; // the reference we receive to the list
> >
> > var getCellIndex : Function; // the function we receive from the
list
> >
> > var getDataLabel : Function; // the function we receive from the
list
> >
> > function changeVal() {
> >
> > val = changed.value;
> >
> > listOwner.editField(getCellIndex().itemIndex, getDataLabel(),
> > val);
> >
> > }
> >
> >
> >
> > Relevant links:
> >
> >
http://weblogs.macromedia.com/pent/archives/2004/12/cell_renderers.cfm
> >
<http://weblogs.macromedia.com/pent/archives/2004/12/cell_renderers.cfm>
> >
> >
>
http://weblogs.macromedia.com/pent/archives/flex/solutions/cellrenderers\
\
> > .zip
> >
>
<http://weblogs.macromedia.com/pent/archives/flex/solutions/cellrenderer\
\
> > s.zip> (source)
> >
> >
> >
> > --- In [email protected], "digital_eyezed" <iain.mclean@>
> > wrote:
> > >
> > > Hi all,
> > >
> > > I have a problem with a numeric stepper in a cellrenderer of a
> > > dataGridColumn.
> > >
> > > When the cell loses focus, it goes back to the value set
initially, so
> > > I lose all the changes.
> > >
> > > Here is the cellrenderer code:
> > >
> > > <mx:HBox horizontalAlign="center" width="100%"
> > > xmlns:mx="http://www.macromedia.com/2003/mxml";>
> > > <mx:Script>
> > > <![CDATA[
> > >
> > > var labelData:Object;
> > > var val;
> > >
> > > function setValue(str:String, item:Object) {
> > > if (item == undefined){
> > > visible = false;
> > > return;
> > > }
> > > visible = true;
> > > var s = item;
> > > labelData = s;
> > > val = labelData.levels;
> > > }
> > > function changeVal(){
> > > val = changed.value;
> > > }
> > > ]]>
> > > </mx:Script>
> > > <mx:NumericStepper id="changed" value="{val}" change="changeVal()"
> > > maximum="{labelData.fill}"/>
> > > </mx:HBox>
> > >
> > > I need the numericStepper to keep the value I change it to in each
of
> > > the rows I change it.
> > >
> > > Cheers,
> > >
> > > Iain
> > >
> >
>


Reply via email to