so if it's doing it row by row, then it would need to be a labelfunction event 
right?  where would you suggest the code go?  there needs to be an 
if (datagrid.seleteditem["Kind]=="LONG")datagrid.selecteditem[Profit]="Profit";
then another line that stipulate the other option:
if 
(datagrid.selecteditem[Kind]=="Short")datagrid.selecteditem[Profit]="ShProfit";

--- In flexcoders@yahoogroups.com, "postwick" <p...@...> wrote:
>
> if you just did dataGrid.selectedItem then that would be the selected row.  
> add ["columnname"] to get to the column, so:
> 
> dataGrid.selectedItem["columnname"]
> 
> it's not the label, it's the data column name.
> 
> --- In flexcoders@yahoogroups.com, "Craig" <craigj@> wrote:
> >
> > yes the datagrid is bound to an array collection.
> > I don't want to select any item, I want to change the value of a column's 
> > DataField to a one of two values based on the value of another column's 
> > output.
> > 
> > I don't want to have to 'selecteditem' but I can try that code below are 
> > you suggesting that I use it in the labelfunction of the datagrid column 
> > that I am trying to change?
> > 
> > 
> > --- In flexcoders@yahoogroups.com, "postwick" <paul@> wrote:
> > >
> > > Is the datagrid bound to a collection?  if so, change the value in the 
> > > collection.
> > > 
> > > or try...
> > > 
> > > yourDataGrid.selectedItem["dataColumn1"] = 
> > > yourDataGrid.selectedItem["dataColumn2"]
> > > 
> > > --- In flexcoders@yahoogroups.com, "Craig" <craigj@> wrote:
> > > >
> > > > I am trying to set the value of a column based on the value of another 
> > > > column.  If I use ...selectedItem... it does not work, unless I am 
> > > > mistaken.
> > > > 
> > > > --- In flexcoders@yahoogroups.com, "postwick" <paul@> wrote:
> > > > >
> > > > > You access the value in a column of a datagrid like this...
> > > > > 
> > > > > yourDataGrid.selectedItem["dataColumnNameOfColumn"]
> > > > > 
> > > > > 
> > > > > 
> > > > > --- In flexcoders@yahoogroups.com, "Craig" <craigj@> wrote:
> > > > > >
> > > > > > I GIVE UP!! I have tried everything!!.. I have a dataGrid that 
> > > > > > binds to
> > > > > > an ArrayCollection.  I need to change the value of one columen 
> > > > > > (Profit)
> > > > > > based on the value of another column (Kind) ie.. the results (either
> > > > > > 'LONG' or SHORT').  Here is where I'm at.  I've tried putting code 
> > > > > > into
> > > > > > customer DataGridColumns and labelFunctions and ItemRenderers... 
> > > > > > but can
> > > > > > not do it.  What seem to be working most are events in the DataGrid
> > > > > > Component, better than others, but comparing values in a DataGrid is
> > > > > > obviously impossible.
> > > > > > 
> > > > > > Somehow I need the code to access ArrayCollection getItemat() but I
> > > > > > can't do it!
> > > > > > 
> > > > > > Please help!
> > > > > > 
> > > > > > <mx:DataGrid xmlns:mx="http://www.adobe.com/2006/mxml";
> > > > > >          initialize="initTA()">
> > > > > > 
> > > > > >              <positions:KindColumn id="Kind"
> > > > > >                  headerText="Kind"
> > > > > >                  dataField="Kind"
> > > > > >                  
> > > > > > itemRenderer="com.steury.baseClasses.CellFieldTrd"/>
> > > > > >              <positions:ProfitColumn id="Profit"
> > > > > >                  headerText="Profit"/>
> > > > > > 
> > > > > >      <mx:Script>
> > > > > >          <![CDATA[
> > > > > >          import mx.collections.ArrayCollection;
> > > > > >          import com.steury.baseClasses.*;
> > > > > >          import mx.core.Application;
> > > > > >          import mx.controls.dataGridClasses.DataGridListData;
> > > > > >          import flash.events.Event;
> > > > > >          import mx.core.ClassFactory;
> > > > > >          import com.steury.controls.positions.*;
> > > > > >          import mx.controls.dataGridClasses.DataGridColumn;
> > > > > >          import mx.controls.DataGrid;
> > > > > > 
> > > > > >          private function initTA():String {
> > > > > >              if 
> > > > > > (value[Kind.dataField]=="LONG")Profit.dataField="Profit";
> > > > > >              if
> > > > > > (value[Kind.dataField]=="SHORT")Profit.dataField="ShProfit";
> > > > > >              Profit.itemRenderer=new
> > > > > > ClassFactory(com.steury.baseClasses.CellFieldInt);
> > > > > >              return myDec.format(Profit)+"%";
> > > > > >              }
> > > > > > 
> > > > > > 
> > > > > > 
> > > > > > 
> > > > > > 
> > > > > > 
> > > > > > 
> > > > > > 
> > > > > > --- In flexcoders@yahoogroups.com, "Craig" <craigj@> wrote:
> > > > > > >
> > > > > > > I am trying to access the value of a DataGridColumn and change the
> > > > > > > DataField for another column based on this value...
> > > > > > > Here is my code:
> > > > > > >
> > > > > > > <?xml version="1.0" encoding="utf-8"?>
> > > > > > > <mx:DataGrid xmlns:mx="http://www.adobe.com/2006/mxml";
> > > > > > >               creationComplete="getDp()" >
> > > > > > >
> > > > > > > ... Datagrid>
> > > > > > >         <mx:columns>
> > > > > > >              <mx:DataGridColumn dataField="Ticker"
> > > > > > >                   headerText="Ticker"/>
> > > > > > >              <mx:DataGridColumn id="Kind"
> > > > > > >                  dataField="Kind"
> > > > > > > itemRenderer="com.steury.baseClasses.CellFieldTrd" />
> > > > > > >              <mx:DataGridColumn id="Profit"
> > > > > > >                  headerText="Profit"/>
> > > > > > >
> > > > > > > ActionScript:
> > > > > > >
> > > > > > > private function getDp():void  {
> > > > > > >
> > > > > > if(Application.application.CnvPos.dgOrdExt.selectedItem.Kind=="LONG")Pro\
> > > > > > \
> > > > > > >
> > > > > > fit.dataField="Profit";Application.application.CnvPos.dgOrdExt.refresh()\
> > > > > > \
> > > > > > > ;
> > > > > > > }
> > > > > > >
> > > > > > >
> > > > > > > //This code works find if I use
> > > > > > >
> > > > > > > if(Kind.DataField="Kind")Profit.dataField="Profit";
> > > > > > >
> > > > > > > //above to test the rest of the code.
> > > > > > >
> > > > > > > I can not figure out how to access the value of the 
> > > > > > > Datagridcolumn.  I
> > > > > > > have tied using event listeners, etc.. which did not work.  
> > > > > > > Please let
> > > > > > > me know if anyone can help this fairly simple dilemma.
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>


Reply via email to