0 Replies Latest reply on Jan 2, 2012 10:34 AM by tanuj-flex

    How to get selected values (using checkBox) from DataGrid in flex.

    tanuj-flex

      i have a datagrid which is getting values from a XML file (getting this xml file from database using PHP and HTTP request in flex). i have created a checkbox in every row in data grid. and here is my requirement: i want to select tow or three check-box and would like to get all the values form that particular ROWs in some form , prefered arraycollection (such that i can pass this array directly to a bar chart) .. can some one help me as i am new to flex .

      code ......

       

      <?xml version="1.0" encoding="utf-8"?>

      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" creationComplete="siteData.send()">

                <mx:Script>

                          <![CDATA[

                                    import mx.collections.XMLListCollection;

                                    import mx.controls.*;

                                    import mx.events.ListEvent;

                                    import mx.rpc.events.ResultEvent;

                                    import mx.controls.Alert;

                                    [Bindable] private var fullXML:XMLList;

                                    private function contentHandler(evt:ResultEvent):void{

                                              fullXML = evt.result.values;

                                    }

       

                          ]]>

                </mx:Script>

                <mx:VBox>

                          <mx:Label text="This Data Grid is loading the full XML file"/>

                          <mx:DataGrid width="600"  id="datagrid" dataProvider="{fullXML}">

       

                                    <mx:columns>

                                              <mx:DataGridColumn headerText="Select">

                                                        <mx:itemRenderer>

                                                                  <mx:Component>

                                                                            <mx:HBox horizontalAlign="center">

       

       

                                                                                      <mx:CheckBox id="check"/>

                                                                            </mx:HBox>

                                                                  </mx:Component>

                                                        </mx:itemRenderer>

                                              </mx:DataGridColumn>

                                              <mx:DataGridColumn dataField="release_version" headerText="Release"/>

                                              <mx:DataGridColumn dataField="build" headerText="build"/>

                                              <mx:DataGridColumn dataField="time_login" headerText="time_login"/>

                                              <mx:DataGridColumn dataField="time_tunnel" headerText="time_tunnel"/>

                                              <mx:DataGridColumn dataField="rate_login" headerText="time_tunnel"/>

                                              <mx:DataGridColumn dataField="rate_tunnel" headerText="rate_tunnel"/>

                                    </mx:columns>

                          </mx:DataGrid>

                </mx:VBox>

                <mx:HTTPService url="http://localhost/php_genxml.php" id="siteData" result="contentHandler(event)" resultFormat="e4x"/>

       

       

      </mx:Application>

       

      flex.jpg

      as you can see in the image , i will get this datgrid . now i want to select two or three checkboxes and would like to get all the values form the perticular row (for which check box is selected). i would like to get in array from such that i can driectly pass them to bar chart....

      can some one help me in this. as i m new to flex. or if you have some other suggestion ...My final requirement is: select some values and generate bar gharph for those values.

      please help me in this.

       

      thanks

      tanuj