10 Replies Latest reply on Sep 5, 2009 5:45 AM by _Natasha_

    problem in datagrid?

    435.mahesh Level 1

      i have one application and two components

      RolesDatagrid.mxml

      ----------------------------------

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="444" height="148">
        <mx:Script>
            <![CDATA[
                import mx.core.IFlexDisplayObject;
                import mx.managers.PopUpManager;
                //import components.RolesTitleWindow;
                public function fnAddRoles():void
                {
                    var var_role_title_window:RolesTitleWindow=RolesTitleWindow(PopUpManager.createPopU p(this,RolesTitleWindow,true));               
                      PopUpManager.centerPopUp(var_role_title_window);
                }
            ]]>
        </mx:Script>
          <mx:DataGrid x="0" y="0" width="301" height="94">
              <mx:columns>
                  <mx:DataGridColumn headerText="RoleName"     dataField="col1"/>
                  <mx:DataGridColumn headerText="EmployeeName" dataField="col2"/>
                  <mx:DataGridColumn headerText="Action"       dataField="col3"/>
              </mx:columns>
          </mx:DataGrid>
          <mx:Button x="316" y="72" label="AddRoles" click="fnAddRoles()" styleName="buttonNoOfficial" width="95" height="22"/>
        
      </mx:Canvas>

       

      RolesTitleWindow.mxml

      --------------------------------------

      <?xml version="1.0" encoding="utf-8"?>
      <mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="400" height="250">
        <mx:Script>
            <![CDATA[
                public function fnDivisionRoleName():void
                {
                  
                }
            ]]>
        </mx:Script>
          <mx:ArrayCollection id="id_array1">
              <mx:String>mahesh</mx:String>
              <mx:String>suresh</mx:String>
              <mx:String>babu</mx:String>
          </mx:ArrayCollection>
          <mx:ArrayCollection id="id_array2">
              <mx:String>Pm</mx:String>
              <mx:String>Tm</mx:String>
              <mx:String>ssl</mx:String>
          </mx:ArrayCollection>
          <mx:ComboBox id="id_dividion_role_name" x="48" y="77" width="92" dataProvider="{id_array2}"></mx:ComboBox>
          <mx:ComboBox x="168.5" y="77" width="92" dataProvider="{id_array1}"></mx:ComboBox>
        
          <mx:Button x="94" y="127" label="Add"  click="fnDivisionRoleName();"/>
          <mx:Button x="168.5" y="127" label="Cancel"/>
          
      </mx:TitleWindow>

      App.mxml(application)

      -----------------------------------

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns:local="*">
          <local:RolesDatagrid />
      </mx:Application>

       

       

      This is the code.When ren the application u will get datagrid and addRoles button.wen u click on

      the addRoles button u will get title window.It contains two comboboxes and add button.My

      requirement is select values from two comboboxes and click on add button,then the selected combox

      data will be added to datagrid firstrow(It will contains three fields those are rolename,employeename,action).

      For example if u select comboboxes items are pm,mahesh then i want the datagrid items are

      rolename      employeename     action

      ------------      ------------------------     ----------------

      pm              mahesh             Edit,delte buttons

       

       

       

       

       

      Regards

      D.Mahesh Babu

        • 2. Re: problem in datagrid?
          _Natasha_ Level 4

          public function fnDivisionRoleName():void
                    {
                       var obj:Object = new Object();

                         obj.col1 = id_dividion_role_name.selectedLabel;

                         obj.col2 = id_employee_name.selectedLabel; // create this id for second combobox

                         // and return this object to dataProvider for DataGrid. The easiest way is to dispatch CloseEvent and read a property.
                    }

           

           

          <mx:DataGrid x="0" y="0" width="301" height="94">
                  <mx:columns>
                      <mx:DataGridColumn headerText="RoleName"     dataField="col1"/>
                      <mx:DataGridColumn headerText="EmployeeName" dataField="col2"/>
                      <mx:DataGridColumn headerText="Action"       dataField="col3">

                         <mx:itemRenderer>

          <mx:Component>

          <mx:VBox>

          <mx:Script>

          <![CDATA[

          private function editFcn(data:*):void

          {

          // edit data

           

          }

          private function deleteFcn(data:*):void

          {

          // delete data

           

          }

          ]]>

          </mx:Script>

          <mx:Button label="Edit" click="editFcn(data)"/>

          <mx:Button label="Delete" click="deleteFcn(data)"/>

          </mx:VBox>

          </mx:Component>

          </mx:itemRenderer>

                     </mx:DataGridColumn>
                  </mx:columns>
              </mx:DataGrid>

          • 3. Re: problem in datagrid?
            435.mahesh Level 1

            Thaq natasa.

            If u dont mine can u send me the code for how to send object to dataprovider of

            datadrid of RoleDataGrid.mxml component.

             

             

            Regards

            D.Mahesh Babu

            • 4. Re: problem in datagrid?
              _Natasha_ Level 4

              Something like this:

              RolesDatagrid.mxml

              ----------------------------------

              <?xml version="1.0" encoding="utf-8"?>
              <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="444" height="148">
                <mx:Script>
                    <![CDATA[
                        import mx.core.IFlexDisplayObject;
                        import mx.managers.PopUpManager;
                        //import components.RolesTitleWindow;
                        public function fnAddRoles():void
                        {
                            var var_role_title_window:RolesTitleWindow=RolesTitleWindow(PopUpManager.createPopU p(this,RolesTitleWindow,true));               

              var_role_title_window.addEventListener(CloseEvent.CLOSE, onWindowClose);
                              PopUpManager.centerPopUp(var_role_title_window);
                        }

              private functuion onWindowClose(event:CloseEvent):void

              {

                   var w:RolesTitleWindow = event.target as RolesTitleWindow;

                  if (w)

                   {

                        if (event.details > 0)

                   {

                        var newObj:Object = w.newObject; // new object for dataProvider!

                   }

                    PopUpManager.removePopUp(w);

                   }    

                  

              }

                  
                    ]]>
                </mx:Script>
                  <mx:DataGrid x="0" y="0" width="301" height="94">
                      <mx:columns>
                          <mx:DataGridColumn headerText="RoleName"     dataField="col1"/>
                          <mx:DataGridColumn headerText="EmployeeName" dataField="col2"/>
                          <mx:DataGridColumn headerText="Action"       dataField="col3"/>
                      </mx:columns>
                  </mx:DataGrid>
                  <mx:Button x="316" y="72" label="AddRoles" click="fnAddRoles()" styleName="buttonNoOfficial" width="95" height="22"/>
                
              </mx:Canvas>

               

              RolesTitleWindow.mxml

              --------------------------------------

              <?xml version="1.0" encoding="utf-8"?>
              <mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="400" height="250">
                <mx:Script>
                    <![CDATA[

                        public var newObject:Object;


                        public function fnDivisionRoleName():void
                        {
                           ....

                             newObject = obj;

                             closeMe(1);
                        }

                        private function closeMe(n:Number):void

                        {

                             var clsEvent:CloseEvent = new CloseEvent(CloseEvent.CLOSE, false, false, n);

                             this.dispatchEvent(clsEvent);

                        }
                    ]]>
                </mx:Script>
                  <mx:ArrayCollection id="id_array1">
                      <mx:String>mahesh</mx:String>
                      <mx:String>suresh</mx:String>
                      <mx:String>babu</mx:String>
                  </mx:ArrayCollection>
                  <mx:ArrayCollection id="id_array2">
                      <mx:String>Pm</mx:String>
                      <mx:String>Tm</mx:String>
                      <mx:String>ssl</mx:String>
                  </mx:ArrayCollection>
                  <mx:ComboBox id="id_dividion_role_name" x="48" y="77" width="92" dataProvider="{id_array2}"></mx:ComboBox>
                  <mx:ComboBox x="168.5" y="77" width="92" dataProvider="{id_array1}"></mx:ComboBox>
                
                  <mx:Button x="94" y="127" label="Add"  click="fnDivisionRoleName();"/>
                  <mx:Button x="168.5" y="127" label="Cancel" click="closeMe(-1)"/>
                  
              </mx:TitleWindow>

              • 5. Re: problem in datagrid?
                435.mahesh Level 1

                Thaq.

                Here i have an problem with accessing dataFields(RolesDataGrid.mxml) into the

                function fnDivisionRolename(RolesTitleWindow.mxml).

                I written the code like this:

                 

                RolesTitleWindow.mxml

                ------------------------------------------

                 

                public function fnDivisionRoleName():void
                ������������������ {���� var var_roles_datagrid:RolesDatagrid=new RolesDatagrid();
                �������������������������� var var_rolenames_employeenames:Object=new Object();
                �������������������������� //Here i have an problem with accessing datafields(col1,col2) defined in RolesTitleWindow.mxml
                ��������������������������
                ������������������ }

                plz Help me

                • 6. Re: problem in datagrid?
                  435.mahesh Level 1

                  Thanq

                  I have an problem with accessing dataFileds(RolesDataGrid.mxml) into RolesTitleWindow.mxml(fnDivisionRoleName())

                  RoleTitleWindow.mxml

                  -----------------------------------

                  I have written code like this:

                  public function fnDivisionRoleName():void
                  �������������������� {���� var var_roles_datagrid:RolesDatagrid=new RolesDatagrid();
                  ���������������������������� var var_rolenames_employeenames:Object=new Object();
                  ���������������������������� //Here i have an problem with accessing datafields(col1,col2) defined in RolesDataGrid.mxml
                  ��������������������������
                  �������������������� }

                  plz Help me

                  • 7. Re: problem in datagrid?
                    435.mahesh Level 1

                    Thanq

                    I have an problem with accessing dataFileds(RolesDataGrid.mxml) into RolesTitleWindow.mxml(fnDivisionRoleName())

                    RoleTitleWindow.mxml

                    -----------------------------------

                    I have written code like this:

                    public function fnDivisionRoleName():void
                               {   var var_roles_datagrid:RolesDatagrid=new RolesDatagrid();
                                   var var_rolenames_employeenames:Object=new Object();
                                   //Here i have an problem with accessing datafields(col1,col2) defined in RolesDataGrid.mxml
                                 
                               }

                    plz Help me

                    • 8. Re: problem in datagrid?
                      435.mahesh Level 1

                      hi natasha

                      plz help me.How to achieve that?

                       

                       

                       

                       

                       

                       

                       

                       

                       

                       

                       

                       

                       

                      Regards

                      D.Mahesh Babu

                      • 9. Re: problem in datagrid?
                        _Natasha_ Level 4

                        Hi,

                        sorry for delay.

                        You need to think about the design of your application if you need to do this.

                        • 10. Re: problem in datagrid?
                          _Natasha_ Level 4

                          But of you just want to solve this problem try to use this.parent