Official Content

Consider a shopping form where the products available for purchase are loaded in a freestyle grid. By dragging the product photo to the cart image you add that product to your shopping cart.

image1ddsample1

How To Do It..

1. Define two variables called &productsdt and &productsdtitem, based on the following SDT:

image11sampledd

2. Code the "Drag" Event. The "photo" is an image control loaded for each product in the grid. In the drag event the &productsdtitem is by default an "out" parameter, and is loaded with the productid and productname values.

Event photo.Drag(&productsdtitem)
   &productsdtitem.productid = &ProductId
   &productsdtitem.productname = &ProductName
EndEvent

3. Code the "Drop" Event. "Cart" is the image where products are dropped to be purchased. The "in" parameter for this event should be the &productsdtitem, or any variable based on the same SDT that &productsdtitem is based on.

Event cart.Drop(&productsdtitem)
    msg('Buy ' + &productsdtitem.productname)
EndEvent

Related links: Developing Drag and Drop in Web Panels









Last update: April 2024 | © GeneXus. All rights reserved. GeneXus Powered by Globant