This content has been marked as final. Show 3 replies
An idea I had is to create a new Collection class by extending ArrayCollection. The new class does basically everything ArrayCollection does but keeps the totals separate from the data. Without actually planning it out I don't know if it is a good idea, but I think it is worth exploring.
I think I have a better idea. I think you've already added a row to your data to hold the totals. Make that row unique in some way, such as adding a field called "totals" and setting it to 1 or true or something. Don't add it to the other rows.
You will need to write your own Sort compareFunction, but when you do, check to see if either item has the totals field set and if so, return -1 (or 1) so that it always sorts first. Then no matter what values are in your data, the totals row will always be at the top.
This should be easier than extending ArrayCollection.
Your second Idea i think will be the best in this situation. considering the following, I have the datagrid formatted with "%" and "$" so it sorts the columns as strings and not numbers. So I have to write a new Sort compareFunction anyways to get the columns to sort properly. Currently it sorts 0-9 and does not compare the actual value, hence, this list of numbers(100, 98, 500, 60, 12) would be sorted like (100, 12, 500, 60, 98) and not (500,100,98,60,12).