1 Reply Latest reply on Jul 18, 2008 4:05 PM by ntsiii

    DataGrid: Inconsistent data sent to labelFunction

    mjohnsson Level 1
      Hi all.

      I have a huge statistic dataset (two dimensional array of Number(s)) that I visualize in a couple of ways (using my own components). Now I also want to display some of the data in a DataGrid, but I've run into trouble. The thing is that my dataset and it's metadata is stored separatly (and changing that is not an option), but I want to display metadata along with the statistics; for example: one column with the country name (from metadata) and 5-10 columns with statistics (from the dataset).

      I thought I had the solution to this when I made an IList wrapper for my dataset (DataSetWrapper), that also included the metadata and created (rowMetadata, rowData) pairs (DataSetWrapperRow). The rowData is a reference to the array in the dataset (so no double storage is needed). I then used a function as DataGridColumn::labelFunction that extracts the right value from the DataSetWrapperRow object depending on the column. This worked fine to start with. But all of a sudden, the objects that were sent to my labelFunction wasn't DataSetWrapperRow any more, but the toArray():ed version, which totally screws upp the point of the labelFunction.

      Anyone know why this happens? Why isn't the getItemAt()-version always used when sent to labelFunction?

      And why isn't there a IDataProvider interface that I could have implemented instead of IList? Okay, actionscript support dynamic classes, but depending on properties to extract data from objects isn't very flexible.