I managed to create a (pseudo) merged cell for a project of mine which uses datagrids to display data. Never did see anything online about how to do it, so I had to do a bit of tweaking with cellRenderers. Here’s what I got:
First off, let me note that I made my cell merge occur conditionally. Also, the cells are not truly merged. Of the cells being ‘merged’, the one on the farthest right is brought to the front, then its width is set to the same width of all the cells being merged, and finally it’s x position is set to that of the cell at the farthest left of the cells being merged. Cheep trick, but it works!
Here’s the cell renderer script
package
{
import fl.controls.listClasses.CellRenderer;
import flash.utils.getDefinitionByName;
public class CellMergeRenderer extends CellRenderer
{
public function CellMergeRenderer()
{
super();
}
override protected function drawLayout():void
{
// Condition for which to merge cells (mine was that the cell was not blank)
if (textField.text != " ")
{
// Bring the cell to the front
var Index:Number = parent.getChildIndex(parent.getChildByName(this.name));
parent.swapChildrenAt(Index, parent.numChildren-1);
// set the cell to the width of the combined cells
this.width=320;
// set the cell to the position of the cell to the farthest left of the merged cells
this.x = 0;
}
super.drawLayout();
}
}
}
that’s it! now just set the cellRender of the cell to the farthest right of the cells being merged:
EventGrid.getColumnAt(EventGrid.getColumnIndex(“MyColumn”)).cellRenderer = CellMergeRenderer;