2 Replies Latest reply on Oct 21, 2009 12:33 AM by Geordie Moffatt

    Maybe Flex SDK bug: Setting visible of DataGrid item renderers

    Geordie Moffatt

      Hi all, I'm still a noob at flex but this looks a bit strange to me.

       

      I've been trying to hide a button renderer in a DataGrid but it just wouldn't hide.  I've been setting visible inside the mxml and also in the the class that extends buttonbut it just wouldn't hide.  I then overloaded the visible property set/get and traced what was setting the property to true and found that inside DataGridBase.as the function setupColumnItemRenderer always sets visible of the renderes to true.

       

      DataGridBase.as
      protected function setupColumnItemRenderer(c:DataGridColumn, contentHolder:ListBaseContentHolder,
                          rowNum:int, colNum:int, data:Object, uid:String):IListItemRenderer
          {
              var listItems:Array = contentHolder.listItems;
              var item:IListItemRenderer;
              var rowData:DataGridListData;

              item = listItems[rowNum][colNum];
              if (!item || itemToUID(item.data) != uid
                  || columnMap[item.name] != c)
              {
                  item = createColumnItemRenderer(c, false, data);
                  if (item == null)
                      return null;
                  if (item.parent != contentHolder)
                      contentHolder.addChild(DisplayObject(item));

                  // a space is used if no data so text widgets get some default size
                  columnMap[item.name] = c;
                  if (listItems[rowNum][colNum])
                      addToFreeItemRenderers(listItems[rowNum][colNum]);
                  listItems[rowNum][colNum] = item;
              }

              //[Matt] moved from inside the block above to outside because
              //the item definitely exists at this point, and always needs
              //its data refreshed
              rowData = DataGridListData(makeListData(data, uid, rowNum, c.colNum, c));
              rowMap[item.name] = rowData;
              if (item is IDropInListItemRenderer)
                  IDropInListItemRenderer(item).listData = data ? rowData : null;
              item.data = data;
              item.visible = true;

              if (uid && colNum == 0)
                  contentHolder.visibleData[uid] = item;
              return item;
          }

       

      Why does it do this?  Shouldn't it respect the visible property already set for the renderer in mxml and not force it to true on init?