Search code examples
apache-flexflex-spark

DataGrid column value not showing with labelFunction


I have a Spark DataGrid that I'm using a labelFunction with. However it's not showing any results.

var c3:GridColumn = new GridColumn("Date Added");
c3.width = 150;
//c3.dataField = "date";

c3.labelFunction = getFormattedDateNoTimeGrid;



public function getFormattedDateNoTimeGrid(item:Object, column:GridColumn):String
{
    var rawDate:String = item.date;
    trace("Date:" + rawDate); 
    return rawDate;
}

With the previous code it shows nothing but the label function is called and all the dates correctly trace out. If I remove the dateField line the column is not empty but it's not the value returned by the label function. Basically the label function is not showing the value it is supposed to.


Solution

  • What a pain. Flash Builder "helped" me create a item renderer for my grid column that had this function in it:

    override public function prepare(hasBeenRecycled:Boolean):void {
        lblData.text = data[column.dataField];
    }
    

    That function overrides the functionality of the dataField and labelFunction. I removed it and all is well. Thanks everyone for all your help.