How can I make an AdvancedDataGrid re-display its labels when the results of the labelFunction chang
Posted
by Chris R
on Stack Overflow
See other posts from Stack Overflow
or by Chris R
Published on 2010-03-31T21:50:55Z
Indexed on
2010/03/31
21:53 UTC
Read the original article
Hit count: 491
flex
|actionscript
I have an AdvancedDataGrid with a custom label function whose value can change based on other form status (specifically, there's a drop down to choose the time display format for some columns).
Right now, I have this labelFunction:
internal function formatColumnTime(item: Object, column: AdvancedDataGridColumn): String {
var seconds: Number = item[column.dataField];
return timeFormat.selectedItem.labelFunction(seconds);
}
internal function formatTimeAsInterval(time: Number): String {
if (isNaN(time))
return "";
var integerTime: int = Math.round(time);
var seconds: int = integerTime % 60;
integerTime = integerTime / 60;
var minutes: int = integerTime % 60;
var hours: int = integerTime / 60;
return printf("%02d:%02d:%02d", hours, minutes, seconds);
}
internal function formatTimeAsFractions(time: Number): String {
if (isNaN(time))
return "";
var hours: Number = time / 3600.0;
return new String(Math.round(hours * 100) / 100);
}
... and the timeFormat object is a combo box with items whose labelFunction attributes are formatTimeAsFractions
and formatTimeAsInterval
.
The columns that have time formats have formatColumnTime
as their labelFunction
value, because extracting the seconds in that function and passing it in to the formatters made for a more testable app (IMHO).
So, when the timeFormat.selectedItem
value changes, I want to force my grid to re-calculate the labels of these colums. What method must I call on it? invalidateProperties()
didn't work, so that's out.
© Stack Overflow or respective owner