Here's another way:
<mx:DataGrid id="mygrid" dataProvider="{initDG}" >
<mx:columns>
<mx:DataGridColumn id="grant_year" dataField="grant_year"/>
<mx:DataGridColumn id="cashoutshares" dataField="cashoutshares">
<mx:itemRenderer>
<mx:Component>
<mx:Canvas>
<mx:Script>
<![CDATA[
override public function set
data(value:Object):void
{
super.data = value;
if (value != null)
{
myCheckBox.selected =
data.cashoutshares;
myCheckBox.visible =
data.grant_year == '1995' ? true : false; // your logic
super.invalidateDisplayList();
}
]]>
</mx:Script>
<mx:CheckBox id="myCheckBox"
click="data.cashoutshares=myCheckBox.selected"/>
</mx:Canvas>
</mx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>
</mx:columns>
</mx:DataGrid>
This works because the data property in an itemRenderer contains all of
the fields for a row in a dataGrid's dataProvider.
-TH
--- In [email protected], Manu Dhanda <[EMAIL PROTECTED]>
wrote:
>
>
> Ok, one more idea, but not sure about it's performance.
> Just use a viewstack with your custom itemrenderer and use a text
component
> to implement your blank box logic, keeping the text="".
> Here is my idea:
>
> <mx:DataGrid id="mygrid" dataProvider="{initDG}" >
> <mx:columns>
>
> <mx:DataGridColumn id="grant_year" dataField="grant_year"/>
> <mx:DataGridColumn id="cashoutshares" dataField="cashoutshares"
> itemRenderer="xxxx.yyyy.MyCheckBox" />
>
> </mx:columns>
> </mx:DataGrid>
>
> MyCheckBox.mxml:
> <?xml version="1.0" encoding="utf-8"?>
> <mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml"
> horizontalAlign="center">
>
> <mx:Script>
> <![CDATA[
>
> import mx.events.FlexEvent;
> import com.live.flats.view.assets.FlatAssets;
> import mx.controls.Alert;
>
> public function getStackView(value:Object):void {
> //return ur view here..
> }
> ]]>
> </mx:Script>
>
> <mx:ViewStack selectedChild="{ getStackView( data.cashoutshares) }">
> <mx:CheckBox id="aCB" selected="true">
> <mx:Text id="aText" text=""/>
> <mx:ViewStack>
> </mx:HBox>
>
> Thanks,
> Manu.
>
>
> anthony_morsey wrote:
> >
> > Thanks, but this technique seems to work for all values in the
column,
> > not just the value in each individual row. It seems that if one of
> > the values for grant_year in a column meets the condition, then all
> > checkboxes are either hidden or visible. I want to do this row by
row
> > and turn visible on or off based on the grant_year value in that
row.
> >
> > Any other ideas?
> >
> > Thanks
> >
> > --- In [email protected], Manu Dhanda manuraj.dhanda@
wrote:
> >>
> >>
> >> Here it is:
> >> <mx:DataGrid id="mygrid" dataProvider="{initDG}" >
> >> <mx:columns>
> >>
> >> <mx:DataGridColumn id="grant_year" dataField="grant_year"/>
> >>
> >> <mx:DataGridColumn id="cashoutshares" dataField="cashoutshares"
> >> itemRenderer="mx.controls.CheckBox"
visible="{!grant_year=='somevalue'
> >> implement ur logic here}"/>
> >>
> >> </mx:columns>
> >> </mx:DataGrid
> >>
> >>
> >>
> >> anthony_morsey wrote:
> >> >
> >> > Here is my code:
> >> >
> >> > <mx:DataGrid id="mygrid" dataProvider="{initDG}" >
> >> > <mx:columns>
> >> >
> >> > <mx:DataGridColumn id="grant_year" dataField="grant_year"/>
> >> >
> >> > <mx:DataGridColumn id="cashoutshares" dataField="cashoutshares"
> >> > itemRenderer="mx.controls.CheckBox" />
> >> >
> >> > </mx:columns>
> >> > </mx:DataGrid
> >> >
> >> >
> >> >
> >> > I want to hide the "cashoutshares" column (or turn off the
> >> > itemrenderer in that column) based on the data value of
"grant_year".
> >> >
> >> > Thanks
> >> >
> >> >
> >> >
> >> >
> >> >
> >> >
> >> > --- In [email protected], "jmfillman" <jmfillman@>
wrote:
> >> >>
> >> >> Anthony,
> >> >>
> >> >> If you are passing the data from the columns of each row to the
> >> >> itemRenderer, you should be able to set visibility conditions
> > from the
> >> >> itemRenderer.
> >> >>
> >> >> If you post your code, I or someone else here might be able to
> > provide
> >> >> a more specific suggestion.
> >> >>
> >> >> JF
> >> >> --- In [email protected], "anthony_morsey" <tmorsey@>
wrote:
> >> >> >
> >> >> > I have a datagrid with multiple columns and rows. One of the
> > columns
> >> >> > contains a checkbox which is rendered with an itemRenderer.
> > I'd like
> >> >> > to conditionally hide some of these checkboxes based on values
from
> >> >> > other columns with the same row.
> >> >> >
> >> >> > Any ideas?
> >> >> >
> >> >> > Thanks
> >> >> >
> >> >>
> >> >
> >> >
> >> >
> >> >
> >>
> >> --
> >> View this message in context:
> >
http://www.nabble.com/hiding-a-cell-within-a-datagrid-dynamically-tp1767\
3007p17688100.html
> >> Sent from the FlexCoders mailing list archive at Nabble.com.
> >>
> >
> >
> >
> >
>
> --
> View this message in context:
http://www.nabble.com/hiding-a-cell-within-a-datagrid-dynamically-tp1767\
3007p17703698.html
> Sent from the FlexCoders mailing list archive at Nabble.com.
>