GRD_INTPROD Grid Component

Purpose

The application administrator uses the GRD_INTPROD grid component to maintain product records.

The Search Part of the GRD_INTPROD grid component

The GRD_INTPROD grid component

The Detail View Part of the GRD_INTPROD grid component

Description

The RD_INTPROD component is a tabular grid with search and detail view parts. The grid is based on a view that combines the product, product_category, and vendor tables.

The GRD_HISTCUST component has a calculated field.

prodid = Product_Id

Containers

ASWPRODUCTS.A5W

Notable Grid Control Property Settings

Control

Property

Description

Product_Id

Display Settings > Control type

"Link"

Link Properties > Display what in link

"Value in Field"

Link Properties > Link Address type

"DetailView link"

Thumbsm

Image Properties > Image path

"[PathAlias.ADB_Path]"

Notable Search Control Property Settings

Control

Property

Description

Cat_Id

Display Settings > Control type

"DropDownBox"

DropDownBox Properties > Choices

Define Choices > List Type is "Dynamic"

Data Source > Table Name is "product_category"

Data Source > Display value is "Category"

Data Source > Stored value is "Cat_Id"

Vendor

Lookup > Lookup

"True"

Lookup > Lookup Definition

Lookup Window > Grid name is "grd_lkven"

Field Mapping > Field map is "Vendor<Vendor_id"

Advanced > Override settings:

field_info[3].Column.Hide = .T."

Notable Search Part Property Settings

Property

Description

Search Options > Enable Show/Hide of Search Part

"True"

Search Options > Initial State

"Closed"

Lookup > Lookup

"True"

Lookup > Lookup Definition

Lookup Window > Grid name is "grd_lkven"

Field Mapping > Field map is "Vendor<Vendor_id"

Advanced > Override settings:

field_info[3].Column.Hide = .T."

Notable Detail Control Property Settings

Control

Property

Description

Product_Id

Display Settings > Control type

"Hidden"

Vendor

Lookup > Lookup

"True"

Lookup > Lookup Definition

Lookup Window > Grid name is "grd_lkven"

Field Mapping > Field map is "Vendor<Vendor_id,Venname<Name"

Row Properties > Freeform layout

"True"

Row Properties > Freeform template

{Venname}&nbsp;{Vendor}

Venname

Row Properties > Hide row

"True"

Cat_Id

Lookup > Lookup

"True"

Lookup > Lookup Definition

Lookup Window > Grid name is "grd_lkcats"

Field Mapping > Field map is "Cat_id<Cat_id,Category<Category"

Row Properties > Freeform layout

"True"

Row Properties > Freeform template

{Category}&nbsp;{Cat_Id}

Category

Row Properties > Hide row

"True"

Ship_Avail

Display Settings > Control type

"DropDownBox"

DropDownBox Properties > Choices

Define Choices > List Type is "Dynamic"

Data Source > Table Name is "lk_avail"

Data Source > Display value is "Ship_Avail"

Thumb

Row Properties > Hide row

"True"

The AfterUpdateRecords event of the grid defines the values of these fields.

Thumbsm

Row Properties > Hide row

Picture

Row Properties > Hide row

AfterUpdateRecords Event

The script initially tests to see if the product_id control in the first row of the grid exists and is not NULL.

function AfterUpdateRecords as v (Args as P, PageVariables as P)

with PageVariables

    if eval_valid("Args.DataSubmitted.R1.PRODUCT_ID") = .T. ' only update if not deleted

        dim prod_id as C

        prod_id = Args.DataSubmitted.R1.PRODUCT_ID

        if prod_id <> ""

Next, the script opens the product table and orders its records by product_id.

            ext = "jpg"

            img_path = "[PathAlias.ADB_Path]\Images\\"

            rel_path = "Images\\"

            def_image = "noimage"

            tbl = table.open("[PathAlias.ADB_Path]\product.dbf")

            tbl.order("product_id")

If a record is found, the script updates the values of the picture, thumb, and thumbsm fields. In each case, if the image file exists, the script writes the appropriate path information into the table. If the image file does not exist, it writes "noimage" into the table.

            if tbl.fetch_find(prod_id) > 0

                tbl.change_begin()

                if file.exists(img_path +  alltrim(tbl.Product_id) + ext)

                    tbl.picture = "=filename_decode(\"" + rel_path + alltrim(tbl.Product_id) + "." + ext + "\")"

                else

                    tbl.picture = "=filename_decode(\"" + rel_path +  def_image + "." + ext + "\")"

                end if

                if file.exists(img_path + alltrim(tbl.Product_id) + "_TL." + ext)

                    tbl.Thumb = "=filename_decode(\"" + rel_path + alltrim(tbl.Product_id) + "_TL." + ext + "\")"

                else

                    tbl.Thumb = "=filename_decode(\"" + rel_path +  def_image + "_TL." + ext + "\")"

                end if

                if file.exists(img_path + alltrim(tbl.Product_id) + "_TS." + ext)

                    tbl.Thumbsm = "=filename_decode(\"" + rel_path +  alltrim(tbl.Product_id) + "_TS." + ext + "\")"

                else

                    tbl.Thumbsm= "=filename_decode(\"" + rel_path +  def_image + "_TS." + ext + "\")"

                end if

                tbl.change_end()

            end if

            tbl.close()

        end if

    end if

end with

end function

See Also

Web Publishing Components

Supported By

Alpha Five Version 7 and Above