Thanks for the reply, this is what I did to get it to work so far:

I created a value object class to hold exactly the data I wanted for each row 
in the datagrid. When the php service returned the data I looped throught it 
and transfered what I needed to instances of my VO and then added those to a 
new array collection. That array collection I then bound as a dataprovider for 
my datagrid.

I put in an inline item renderer for the amount with a numeric stepper.

The next step will then be to take the correct data from that array collection 
(item id and item amount) and transfer it to a php service that will save it in 
the order-table of the database. 

Since the grid and the ac are bound, I do not need to fire an event on focus 
out, I already have the data in the ac. I wonder how that solution might have 
worked when the user changes her mind and alters the amount many times on the 
products(?)


--- In [email protected], "valdhor" <valdhorli...@...> wrote:
>
> First off, adding this one column datagrid and getting it to line up 
> correctly must be a pain. I wouldn't do that. Just add another column to the 
> datagrid for the quantity. You can add as many columns to the datagrid as you 
> want - they do not have to match the dataprovider.
> 
> I would design my item editor with a textfield with a focus out event 
> listener. When the event fires, grab the ID, amount and price and populate a 
> value object. Add this object to a custom event and dispatch it.
> 
> At the same level of the datagrid (Or wherever), have an event listener for 
> the custom event. When you get it, add the value object to an orders array 
> collection. If the user commits to buy, send this array collection to the 
> server to populate the orders database. You can return the order number and 
> save it in a shared object if you want.
> 
> 
> --- In [email protected], "henrik.hedberg" <henrik@> wrote:
> >
> > 
> > Hi guys, quite an explanation here, hope someone has the patience to
> > read it through
> > 
> > I'm building an application in Flex 4 that handles an ordering  system.
> > I have a small mySql database and I've written a few services in  php to
> > handle the database.
> > 
> > Basically the logic goes like this:
> > 
> > I have tables for customers, products, productGroups, orders, and
> > orderContent
> > 
> > I have no problem with the CRUD management of the products, orders  and
> > customers, it is the order submission that the customer will fill in 
> > that is giving me headaches:
> > 
> > What I want is to display the products in dataGrids, ordered by  group,
> > which will be populated with Flex datamanagement via the  php-services,
> > and that per se is no problem. But I also want an extra  column in the
> > datagrid that the user can fill in with the amount he  wishes to order
> > of that product. This column would in theory then bind  to the db table
> > "orderContent" via the php services.
> > 
> > The problem is that you would need to create a new order in the 
> > database first that the data could bind to (orderContent is linked to an
> > order in the db).
> > 
> > I do not want to create a new order every time a user enters the page 
> > to look at the products, rather I would like to create the order when a 
> > button is pressed and then take everything from the datagrids on the 
> > page and submit it into the database.
> > 
> > My idea has been to create a separate one-column datagrid, line it up 
> > next to the datagrid that contains the products and in that datagrid 
> > the user would be able to enter the amount of that product he'd like to 
> > order.
> > 
> > I've created a valueObject that contains the data I would need for an
> > order:
> > 
> > Code:
> > package valueObjects
> > {
> >    public class OrderAmount
> >    {
> > 
> >      public var productId:int;
> >      public var productAmount:int;
> >      public var productPrice:Number;
> > 
> >      public function orderAmount()
> >      {
> >      }
> >    }
> > }
> > 
> > My idea was to use a service to get all products from a certain  group,
> > populate an ArrayCollection with the data, then transfer each  object in
> > that ArrayCollection to an instance of the Value Object above,  add the
> > value object to another ArrayCollection that would the be used  as a
> > dataProvider for the one-column datagrid (I would only display  amount
> > which would be set to zero at first, but use the other data upon 
> > transfering it to the db)
> > 
> > I've tried to use the results from the automatically generated 
> > serviceResults that retrieve the products for the datagrid and put in a 
> > resultHandler that transfers the valueobjects, however this does not 
> > seem to work.
> > 
> > Basically my question is this: Am I approaching this thing completely 
> > wrong, is there a better solution?
> > 
> > Would I need to create a completely new service request to get the
> > product id:s, and price to populate the one-column datagrid.
> > 
> > I'll post some code if that would help.
> > 
> > Thank you if you read this far.
> >
>


Reply via email to