3 Replies Latest reply on Apr 7, 2009 2:00 PM by Michael Borbor

    datagrid: when click on cell provide more info

    newbieal

      I've a datagrid and I need to add functionality that when user clicks on a cell that a pop-up is enabled with additional information regarding the cell content.  How can this be accomplished?  Any sample code and/or tutorial on this would be greatly appreciated.

        • 1. Re: datagrid: when click on cell provide more info
          nikos101 Level 2

          I've done this with advanced datagrids using itemClick method:

           

            <mx:itemClick>
                      <![CDATA[
                      var t1:Object = (event as ListEvent ).itemRenderer;
                      var t:Object = ((event as ListEvent ).itemRenderer as  AdvancedDataGridItemRenderer);//if a simple no group data
                      if(t!=null){
                          if(!hasPopup){
                              if (true)
                              {
                                  var p:PopupBagNumber=new PopupBagNumber();
                                  p.initialize();
                                  p.key = ((event as ListEvent ).itemRenderer as  AdvancedDataGridItemRenderer).data.key;
                              //    p.deals.dataProvider=event.result;
                                  PopUpManager.addPopUp(p, this, true);
                              }
                              hasPopup = true;           
                          }
                      }
                      else if(event.columnIndex == 0 && !(((event as ListEvent ).itemRenderer as  AdvancedDataGridGroupItemRenderer).listData as AdvancedDataGridListData).hasChildren ){
                          if(!hasPopup){
                              if (true)
                              {
                                  p=new PopupBagNumber();
                                  p.initialize();
                                  p.key = ((event as ListEvent ).itemRenderer as  AdvancedDataGridGroupItemRenderer).data.key;
                              //    p.deals.dataProvider=event.result;
                                  PopUpManager.addPopUp(p, this, true);
                              }
                              hasPopup = true;           
                          }
                      }
                      ]]>
                  </mx:itemClick>

           

           

           

           

          the most useful line of code for you is

           

            p.key = ((event as ListEvent ).itemRenderer as  AdvancedDataGridItemRenderer).data.key;

          • 2. Re: datagrid: when click on cell provide more info
            newbieal Level 1

            I'm very new to Flex.  I appreciate your example, however I just have a simple datagrid with XML datasource.  Would you have a more simple example that would accomplish this?