开发者

What's the equivalent of this Flex MX code in Spark?

What's the equivalent of an inline itemRenderer checkbox element in spark?

<mx:AdvancedDataGridColumn headerText="Eliminar" dataField="eliminar"  width="100" textAlign="center">
                    <mx:itemRenderer>
                        <fx:Component>
                            <mx:HBox horizontalAlign="center">
                            <mx:CheckBox id="chkEliminar" change="{data.eliminar = chkEliminar.selected}" selected="{data.eliminar}"/>
                       开发者_运维知识库     </mx:HBox>
                        </fx:Component>                     
                    </mx:itemRenderer>
                        </mx:AdvancedDataGridColumn>


Inline itemRenderers work the same in spark as they did in Halo.

Spark has its own CheckBox component <s:CheckBox> you could use, but you can also continue to use the Halo CheckBox <mx:CheckBox> you've got in your example.


+1 for Jason's answer

Inline itemRenderers work the same in spark as they did in Halo

I will add that if you want to use Spark Components in a renderer, then you either need to implement IDataRenderer interface or use the itemRenderer class. More info here. I would rewrite your existing itemRenderer like this to be Spark:

<fx:Component>
<s:ItemRenderer>
 <s:CheckBox id="chkEliminar" change="{data.eliminar = chkEliminar.selected}" selected="{data.eliminar}"/>
</s:ItemRenderer>
</fx:Component>   

For the moment, I'm ignoring the act that binding in an itemRenderer is consdered a bad practice and you really should use the dataChange event to modify the selected values.


Both of the other answers here are good for this case, where there's only one subitem, but if you want the itemrenderer to have a layout like an HBox you need to specify it manually:

<s:itemRenderer>
  <fx:Component>
    <s:itemRenderer>
       <s:layout>
         <s:HorizontalLayout horizontalAlign="center"/>
       </s:layout>
       <mx:CheckBox id="chkEliminar" change="{data.eliminar = chkEliminar.selected}" selected="{data.eliminar}"/>
     </s:itemRenderer>
   </fx:Component>                     
 </s:itemRenderer>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜