views:

517

answers:

2

I have a data grid. How can I hide a value of a column if it's "0" ? Do I have to use item renderers? How? Is there an easier way?

Second thing, if I have a boolean column whose values are actually the strings "true" and "false" how can I render it as a non editable check box?

thanks

+2  A: 

First question: you can do it with labelFunction property of datagridcolumn.

<mx:DataGridColumn dataField="fieldValue" editable="false"
  labelFunction="hideZero">
private function hideZero(item:Object, column:DataGridColumn):String
{
  if(item.fieldValue == 0)
    return "";
  return item.fieldValue;
}

second question: use a drop in item renderer.

<mx:DataGridColumn dataField="dValue" editable="false">
  <mx:itemRenderer>
    <mx:Component>
      <mx:CheckBox selected="{data.dValue == 'true'}"/>
    </mx:Component>
  </mx:itemRenderer>
</mx:DataGridColumn>

replace dValue with appropriate dataField.

Amarghosh
A: 

I wanted to hide the checkbox when the boolean value is false. Not able to do it using visible="{data.dValue == 'false'}" WHat is the correct way to do it??

Guruji