tags:

views:

78

answers:

1

I have an editable DataGrid in Flex, with data full of numbers. The columns have no special itemRenderer, but a labelFunction, which returns the number as-is if positive, but puts it in parentheses if it is negative, like so

27.3 => "27.3"
-27.3 => "(27.3)"

Now, these cells are editable. When I try to edit a cell with a positive number, nothing is wrong. But if I try to edit a negative number, it starts editing (27.3) instead of editing -27.3. Because of this, when the edit is done, the labelFunction is evaluated with the new value in parentheses(i.e., labelFunction is called with "(30.5)"), and converting it to a Number results in NaN.

So, I want to know if I can make the DataGrid edit the data in the dataProvider instead of the label that it shows.

I hope I am clear with the condition. Please ask if you need any clarification.

Thank you.

+1  A: 

Is this what you're after?

Example: Modifying data passed to or received from an item editor - From livedocs.adobe.com

(You may still have to scroll down once the page loads... The anchor doesn't seem to be working for me.)

echo
which part of it do you mean?, I can't find any mentions of labelFunction. **EDIT**: Sorry, looking into it now :)
Shrikant Sharat
So, I should have a handler for itemEditBegin, which will change the parentheses notation to the normal negative number notation... This method feels error-prone. Am I missing something?
Shrikant Sharat
That's what I would try. I think if you're performing custom formatting when the value is bound to the cell, you will have to implement the corresponding parse function to allow editing.
echo
But I expected it to edit the value that is in the dataProvider, not the value it displays.. which could've been an image.. how would it edit an image :P. If it edits the value in the dataProvider, I shouldn't be having this problem. Thanks for the solution btw.
Shrikant Sharat
Wait, an image? I must be missing something... Maybe if you post some code...
echo
I was just stating an example.. but it just occured to me that an image needs an itemRendrer, sorry.
Shrikant Sharat