2011-12-05 47 views
0

我有一個複選框作爲itemRenderer在我的數據網格中。我正在從我的數據庫表中的列中設置選定的值。該變量的值爲「true」,但我的複選框被選中,儘管我將其選定屬性設置爲true的數據字段。複選框itemrenderer在datagrid中顯示錯誤的選定值

我的代碼如下:

<mx:DataGrid id="myGD" fontSize="9" enabled="true" x="20" y="20" width="217" height="60"> 
    <mx:columns> 
     <mx:DataGridColumn rendererIsEditor="true" editorDataField="selected" width="20" headerText="isDefault" dataField="IS_DEFAULT"> 
      <mx:itemRenderer> 
       <fx:Component> 
        <mx:HBox horizontalAlign="left"> 
         <s:CheckBox selected="{Boolean(data['IS_DEFAULT'])}" horizontalCenter="0"/> 
        </mx:HBox> 
       </fx:Component> 
      </mx:itemRenderer> 
     </mx:DataGridColumn> 
    </mx:columns> 
</mx:DataGrid> 

有人可以幫助我明白是怎麼回事錯在這裏? 非常感謝

回答

0

項目渲染器應該看起來像這樣。其實,我的真實和虛假的價值是作爲字符串發送。 因此,兩者都被評估爲真。

<mx:itemRenderer> 
    <fx:Component> 
     <mx:HBox horizontalAlign="left"> 
      <s:CheckBox selected="{data.MY_FIELD == 'false' ? false : true}" horizontalCenter="0"/> 
     </mx:HBox> 
    </fx:Component> 
</mx:itemRenderer>