Tuto WEBDEV 25
Part 4: Internet site with data 147 5. Create a new attribute by clicking the "New" button: • Rename the attribute to ’ATT_ID’. • Select the "STC_Product" control. • Select the "Caption" property. Indeed, the control caption will be modified for each row. 6. Validate the description window of Looper control. 7. Save the modifications ( or Ctrl + S). The Looper control is created now. Let’s now program the fill operation for the Looper control. Fill of the Looper control The Looper control is filled when initializing the page. ▶ To fill the Looper control: 1. Display the WLanguage events associated with the page (click inside the page and select "Code" in the popup menu, or press F2). 2. Write the following code in the "Initializing" event of the page: FOR EACH Product WITH NewProduct = True LooperAddLine(LOOP_NewProducts,Product.Visual,... Product.Caption,Product.ProductID) END 3. Let’s take a look at this WLanguage code: • This code browses the Product data file via the FOR EACH statement. • Only the records for which the "NewProduct" item is set to True are selected. • LooperAddLine is used to add a new row into the Looper control. The different row attributes are updated with the data of current record: • the "ATT_Image" attribute value corresponds to the image found in the "Visual" item of the "Product" data file. • the value of the "ATT_Link" attribute caption is the content of the "Caption" item found in the "Product" data file. • the value of the "ATT_ID" attribute caption is the content of the "ProductID" item found in the "Product" data file. 4. Save the modifications ( or Ctrl + S). 5. Close the code window.
Made with FlippingBook
RkJQdWJsaXNoZXIy NDQ0OA==