Okay, so I found a solution that works for me. Here follows.
Basically, on creationComplete
I call the sortData
function that does the following.
private function sortData():void {
var sort:Sort = new Sort();
var sortField:SortField = new SortField("Product");
sort.fields = [sortField]; // Set 'Product' as the field to be sorted on
myADG.dataProvider.sort = sort; // Add the sort to the dataProvider of the dataGrid
gc.source.refresh(); // Refresh the GroupCollection
}
Hope to see another way of doing this, as I cant think that this is the only way of doing it
After much closer inspection this morning, the meausre method for the DataGroup renderers themselves was not correclty validating the size of its children upon first measure pass.
I need the labels in those items to have a restricted width so they will wordwrap appropriately, so when I am measuring the DataGroup row I need to set the width of each of its children and then measure the child. The problem was validateSize() was not correctly validating the elements size (the label was not being updated and generating its new text lines at this point). All subsequent measure passes already had a width validated to each child so measuring them again was correct. So when resizing the grid, the subsequent measure calls worked.
I took to forcibly validating each child within the DataGroup's measure method and the correct heights are now being returned and as such the AdvancedDataGrid is acutally sizing its rows correclty now.
This can be rather inefficient as each item is validated twice per lifecycle pass now, but the grid is performing as desired.
Probably something similar going on with the ScrollingLabelItemRenderer as the label probably doesn't get its width validated when it measures itself the first time thus sets the wrong measured size which the grid accepts and uses as row height.
I have the ScrollingLabelItemRenderer functioning correctly now again, I had to forcibly apply a width to the label and validate it when measuring the renderer becuase it was still using its previous width and text lines when measuring before applying a new width in the subsequent updateDisplayList ...
override protected function measure():void
{
label.width = getExplicitOrMeasuredWidth() - verticalScrollBar.getExplicitOrMeasuredWidth();
label.validateNow();
super.measure();
}
Best Answer