PDA

View Full Version : [AS2] DataGrid Problem


trendykarn
06-17-2009, 12:17 PM
Hello to all.

I am again here with some trouble.
I have a datagrid that holds data for my shoppingCart like object name,price, quantity.
what I want to know is that How could I change Quantity of an object so that total prize also change respectively

rocker
06-18-2009, 07:08 PM
Exactly the problem that I was facing. I wanted cell B to be notified when something in cell A changed. I got it working by sending an event from cell A to the parent and catching the event in cell B.

See thread http://www.actionscript.org/forums/showthread.php3?t=209522

trendykarn
06-19-2009, 11:42 AM
thank you rocket,
For your help,
But I cant understand what do you mean there in thread,
How to add itemrenderer and catching event for datagrid.
actually can you plz elaborate that or any code.
plz

Thanks again

rocker
06-19-2009, 07:47 PM
What you need is a custom cell renderer for your datagrid. If your datagrid columns are of different types, you will need a custom cell renderer for each of the columns. See this thread http://www.actionscript.org/forums/showthread.php3?t=203892 on how to implement the custom cell renderer (this is in AS3, I have no idea about AS2, but I guess it should be similar).

Then, to notify cell B of any change in cell A, the sequence is as follows:

1. In B's cell renderer, you should have this.parent.addEventListener(MyCustomEvent.EVENT, ....);
2. When change happens in cell A, post an event from here (cell renderer) to the parent movie.
3. This event will be 'caught' in cell B and you can change its data as needed.

The event flow looks something like this then-

Cell A --> Parent Movie <-- Cell B.