4 Replies Latest reply on Jan 25, 2010 9:41 AM by 435.mahesh

    how to remove item renderers from datagrid?

    435.mahesh Level 1

      Hi,

      I have an datagrid.It will contains four columns.First column contains checkbox with label,second column contains combobox,

      third column contains radio button with label and fourth column contains delete button.I have used external itemrenderes for these

      to display as one row.My requirement is when i click on delete button in that row then the corresponding itemrenderes(only)

      are removed(dont remove the row).How to do this?If any code plz send me

       

       

       

       

       

       

       

       

      Regards

      D.Mahesh babu

        • 1. Re: how to remove item renderers from datagrid?
          archemedia Level 4

          In your itemRenderer, use a viewStack or a container in which you can add or remove childItems. Depending on a user action, you can then switch the viewState or delete a childItem as desired.

          If necessesary, I'll make an example.

           

          Dany

          • 2. Re: how to remove item renderers from datagrid?
            435.mahesh Level 1

            Thanks Dany for reply.

            Here i have used checkboxrenderer.mxml(first column),comboboxrenderer.mxml(second column),

            Radiobuttonrenderer.mxml(Third column),deletebuttonrenderer.mxml(fourth column).

            Here my requiremnet is when i click on delete button in fourth column i have to remove(checkbox,

            combobox,radiobuttion item renderers),dont remove row.Cnau send me any example.

             

             

             

             

            Regards

            D.Mahesh babu

            • 3. Re: how to remove item renderers from datagrid?
              archemedia Level 4

              Something like this?

               

              <?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.collections.ArrayCollection;
                         
                          [Bindable]
                          private var dp:ArrayCollection;
                         
                          private function init():void
                          {
                              var arr:Array = [{checkBoxValue: 1, deleted: false}, {checkBoxValue: 0, deleted: false}];
                              dp = new ArrayCollection();
                              dp.source = arr;
                          }
                         
                          internal function handleDelete(evt:Event):void
                          {
                              dg.selectedItem.deleted = true;
                              dp.refresh();
                          }
                         
                      ]]>
                  </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="{data.checkBoxValue}"
                                              includeInLayout="{!data.deleted}"
                                              visible="{!data.deleted}"/>
                                      </mx:VBox>
                                  </mx:Component>
                              </mx:itemRenderer>
                          </mx:DataGridColumn>
                          <mx:DataGridColumn headerText="delete">
                              <mx:itemRenderer>
                                  <mx:Component>
                                      <mx:Button
                                          label="delete"
                                          click="outerDocument.handleDelete(event)"
                                          enabled="{!data.deleted}"/>
                                  </mx:Component>
                              </mx:itemRenderer>
                          </mx:DataGridColumn>
                      </mx:columns>
                  </mx:DataGrid>
              </mx:Application>

               

              Dany

              • 4. Re: how to remove item renderers from datagrid?
                435.mahesh Level 1

                Tanks dany.

                Here i want when i click on delete button,then remove the checkbox.

                Here u u have done as invisible.How to remove checkbox itemrenderer?

                 

                 

                 

                 

                Regards

                D.Mahesh Babu