2 Replies Latest reply on Apr 30, 2008 6:32 AM by TheFlexMan

    DataGrid Headaches

      We have a serious issue when it comes to datagrids in Flex 2 and 3. Our datasource is a simple XML and what we are trying to do is display a checkbox in a datagrid that is binded to a node in the XML. For some reason, the checkbox cannot be binded .. all it does is display checked (true) all the time. I've researched this issue on the internet and, for the mostpart, people use an array data source. In the REAL world however, this cannot always be the case.

      Here is my XML:

      <mx:XMLList id="myCostVendor">





      Note: we are trying to bind the 'recselected' node. It has a value of either true or false.

      Here is the datagrid setup that currently does not work:

      <mx:DataGridColumn headerText="Select" dataField="recselected" width="30">

      <mx:Box width="100%" height="100%" horizontalAlign="center" verticalAlign="middle">
      <mx:CheckBox selected="{data.recselected}" />



      So that's it guys. I really appreciate any help we could get.


        • 1. Re: DataGrid Headaches
          ntsiii Level 3
          Well first, the xml text node will always be a string. The string "true" is not a boolean value, which is what the selected property needs.

          Try a ternary expression:
          selected="{(data.recselected.text() =='true')? true;false}"

          Now, that rendere will not work as is, because it does not save the selected state to the dataProvider. Renderers are recycled, and the ui state must always be determined form the dataProvider item.

          Have the renderer set the recselected propert on change.

          I have a full but simple example of a renderer on www.cflex.net. Search for itemrenderer.


          • 2. Re: DataGrid Headaches
            TheFlexMan Level 1
            Hey Tracy:

            Thank you so much for your response. I was already experimenting with a ternary expression and finally got it to work. Also, thanks for the tip regarding www.cflex.net .. it's a WEALTH of information.

            Best regards,