2 Replies Latest reply on Sep 15, 2011 4:26 PM by fresher4flex

    AdvancedDataGrid Problem: DropDownList ItemRenderer/Editor with Grouping

    WebTrauma

      I am having a problem getting the AdvancedDataGrid to render when I use a Spark dropdownlist as an item renderer/editor within GroupedData. The ADG has been extended to hold an ArrayCollection for my ddlist. That part works fine.

       

      The ddlist control appears both on the child node (good) as well as the parent node (bad).

       

      I have studied the examples and can't find anything wrong with my code.

       

      Is this a bug or am I missing something?

       

      Thanks!

       

       

      AdvancedDataGrid:

       

      <util:MyAdvDataGrid x="10" y="25" width="98%" id="dgItem" paddingLeft="25" paddingRight="25" paddingTop="25" paddingBottom="25" 
                                      itemList="{acItem}"
                                      initialize="gc.refresh();"
                                      sortExpertMode="true"
                                      creationComplete="dgRule_creationCompleteHandler(event)"
                                      height="580">
                <util:dataProvider>
                     <mx:GroupingCollection2 id="gc" source="{acStuff}">
                          <mx:grouping>
                               <mx:Grouping label="Group Name">
                                    <mx:GroupingField name="myGroupName"/>
                               </mx:Grouping>
                          </mx:grouping>
                     </mx:GroupingCollection2>
                </util:dataProvider>
                <util:columns>
                     <mx:AdvancedDataGridColumn id="groupCol" headerText="Group" dataField="myGroupName"/>
                     <mx:AdvancedDataGridColumn id="col1" headerText="Column 1" dataField="itemName" itemRenderer="components.MyItemEditor" 
                                                      rendererIsEditor="true" editable="true"/>
                     <mx:AdvancedDataGridColumn id="col2" headerText="Column 2" dataField="field2" 
                                                      editable="false"/>
                     <mx:AdvancedDataGridColumn id="col3" headerText="Column 3" dataField="field3" 
                                                      editable="false"/>
                     <mx:AdvancedDataGridColumn id="col4" headerText="Column 4" dataField="field4" 
                                                      editable="false"/>
                </util:columns>
           </util:MyAdvDataGrid>
      

       

       

      ItemRenderer:

       

      <?xml version="1.0" encoding="utf-8"?>
      <mx:HBox xmlns:fx="http://ns.adobe.com/mxml/2009" 
                 xmlns:s="library://ns.adobe.com/flex/spark" 
                 xmlns:mx="library://ns.adobe.com/flex/mx" width="100" height="32"
                 paddingLeft="15">
           <fx:Script>
                <![CDATA[          
                     import mx.collections.ArrayCollection;
                     import spark.events.IndexChangeEvent;
                     import utilities.MyAdvDataGrid;
                //
                     [Bindable]
                     protected var acItem:ArrayCollection = new ArrayCollection();
                //
                     override public function set data( value:Object ) : void 
                     { 
                          acItem = (owner as MyAdvDataGrid).itemList;
                     }
                //
                     protected function dropdownlist_changeHandler(e:IndexChangeEvent):void
                     {
                          //
                     }
                //
                     override protected function commitProperties():void 
                     { 
                          super.commitProperties(); 
                     }
                     
                ]]>
           </fx:Script>
           <s:DropDownList id="ddlItem" prompt="Select..." dataProvider="{acItem}" labelField="itemName"
                               change="dropdownlist_changeHandler(event)"
                               width="90%" top="5" bottom="5" left="5" right="5"/>     
      </mx:HBox>
      
      
        • 1. Re: AdvancedDataGrid Problem: DropDownList ItemRenderer/Editor with Grouping
          WebTrauma Level 1

          Update: If I declare the itemEditor inline, it no longer shows up on the collapsed row. However, it does not render at all unless it is clicked on. Once it is rendered, it does not hide itself when the group is collapsed.

           

          I have tried every permutation of editable="true" at the grid level, rendererIsEditor="true" and "false", explicitly definining (and not) an itemRenderer so that it will show the current value when the cell is not clicked, etc.

           

          Nothing will give me the desired behavior:

           

          show/hide ddlist when the group is expanded/collapsed

          OR

          show a TextArea with the current value, then the ddlist itemEditor when the cell is clicked.

           

           

          <util:MyAdvDataGrid x="10" y="25" width="98%" id="dgItem" paddingLeft="25" paddingRight="25" paddingTop="25" paddingBottom="25" 
                                          itemList="{acItem}"
                                          initialize="gc.refresh();"
                                          sortExpertMode="true"
                                          creationComplete="dgRule_creationCompleteHandler(event)"
                                          height="580">
                    <util:dataProvider>
                         <mx:GroupingCollection2 id="gc" source="{acStuff}">
                              <mx:grouping>
                                   <mx:Grouping label="Group Name">
                                        <mx:GroupingField name="myGroupName"/>
                                   </mx:Grouping>
                              </mx:grouping>
                         </mx:GroupingCollection2>
                    </util:dataProvider>
                    <util:columns>
                         <mx:AdvancedDataGridColumn id="groupCol" headerText="Group" dataField="myGroupName"/>
                         <mx:AdvancedDataGridColumn headerText="Item Name" dataField="itemName" editorDataField="itemName" editable="true">
                              <mx:itemEditor>
                                   <fx:Component>
                                        <components:ItemEditorItems/>
                                   </fx:Component>
                              </mx:itemEditor>
                         </mx:AdvancedDataGridColumn>
                         <mx:AdvancedDataGridColumn id="col2" headerText="Column 2" dataField="field2" 
                                                          editable="false"/>
                         <mx:AdvancedDataGridColumn id="col3" headerText="Column 3" dataField="field3" 
                                                          editable="false"/>
                         <mx:AdvancedDataGridColumn id="col4" headerText="Column 4" dataField="field4" 
                                                          editable="false"/>
                    </util:columns>
               </util:MyAdvDataGrid>
          
          • 2. Re: AdvancedDataGrid Problem: DropDownList ItemRenderer/Editor with Grouping
            fresher4flex

            Hi , I am have some problem when I use Dropdownlist  as Itemrendere in Advanced datagrid. If you have figured it out , do let me know

             

            Type Coercion failed: cannot convert spark.components::DropDownList@15d04851 to mx.controls.listClasses.IListItemRenderer.