3 Replies Latest reply on Feb 25, 2010 7:56 AM by venkatsyss

    Regarding Checks and ID

    venkatsyss

      hi,

       

       

      My question regarding checkbox.

       

       

      how i have to check, in  foreach or for loop  if i have selected manually in the  checkbox in itemrender in the datagrid.

       

       

      Please provide me the solution to solve the problem.

       

      Thanks and Regards,

      venkat.R

        • 1. Re: Regarding Checks and ID
          archemedia Level 4

          This is a small example:

           

          <?xml version="1.0" encoding="utf-8"?>
          <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" creationComplete="init()">
              <mx:Script>
                  <![CDATA[
                      import mx.events.FlexEvent;
                      import mx.controls.Alert;
                      import mx.events.CollectionEvent;
                      import mx.collections.ArrayCollection;
                     
                      [Bindable]
                      private var dp:ArrayCollection;
                     
                      private function init():void
                      {
                          var arr:Array = [
                              {ch: 0, label:"bread"}, {ch: 0, label:"milk"}, {ch: 0, label:"eggs"}, {ch: 0, label:"butter"}];
                          dp = new ArrayCollection();
                          dp.source = arr;
                      }
                     
                      public function handleChange(evt:Event):void
                      {
                          dg.selectedItem.ch = evt.target.selected;
                         
                          var sa:Array = new Array();
                         
                          dp.source.forEach(function callback(item:*, index:int, array:Array):void
                          {
                              if (item.ch)
                                  sa.push(item.label);
                          });
                         
                          sList.text = sa.toString();
                         
                      }
                     
                  ]]>
              </mx:Script>
              <mx:DataGrid id="dg" x="10" y="10" dataProvider="{dp}" variableRowHeight="true">
                  <mx:columns>
                      <mx:DataGridColumn headerText="checkBox">
                          <mx:itemRenderer>
                              <mx:Component>
                                  <mx:VBox width="100%" height="100%">
                                      <mx:CheckBox
                                          selected="{Boolean(data.ch)}"
                                          click="outerDocument.handleChange(event)"/>
                                  </mx:VBox>
                              </mx:Component>
                          </mx:itemRenderer>
                      </mx:DataGridColumn>
                      <mx:DataGridColumn headerText="item" dataField="label"/>
                  </mx:columns>
              </mx:DataGrid>
              <mx:Label text="Your shopping list"/>
              <mx:Text id="sList"/>
          </mx:Application>

          • 2. Re: Regarding Checks and ID
            venkatsyss Level 1

            hi,

             

            Thanks for your reply.

             

            After i have manually checked the checkbox however when i have clicked update button, the selected box values are could not able to retrieved.

             

             

            Please provide me the solution to solve the problem.

             

            Thanks and Regards,

            venkat.R

            • 3. Re: Regarding Checks and ID
              venkatsyss Level 1

              hi,

               

              I have successfully got it the answer.

               

              I am very happy to say you have  support me a lot to solve problems.

               

              Thanks a lot.

               

              Thanks and Regards,

              venkat.R