Using Session Variables to Filter a GridLinker


Web publishing applications only. By default a gridlinker displays all of the records of the underlying grid components. To filter a grid (typically the primary grid) in a gridlinker, follow this procedure. Assume you have a gridlinker that links the OrderHeader table (parent) to the OrderItems table (child), and you want to filter the OrderHeader grid so that invoice_number = session.invoice_number.

  1. Open the gridlinker from the Web Projects Control Panel.

  2. Select the grid whose filter you want to override (the top grid in this case).

  3. Click the Edit button to display the Edit Properties dialog.

  4. Click the Override Settings button to display the Override Properties dialog.

  5. Since the invoice_number field links the two grids, you want to enter the following code in the dialog:

    if eval_valid("pgrid.session.invoice_number") then
        dbf.filter = "invoice_number = " + quote(pgrid.session.invoice_number) 
    end if
    In a future version of Alpha Five, the need for the pgrid. prefix in pgrid.session.invoice_number will be eliminated.
  6. Click OK > OK to return to the GridLinker Builder.

  7. Click Save and Close to return to the Web Projects Control Panel.

  8. Place the gridlinker component on a page (in this example named orders.a5w ).

 Testing the Changes

  1. Publish the grid components.

  2. Place the gridlinker component on a page and publish it.

  3. Create a dialog component with a single drop down list control.

  4. Set the DropDownBox Properties > Choices field to display a dynamic list of invoice_number values from the Invoice_Header table.

  5. Display the Form > Properties page.

  6. Click the '...' button in the Server Events > AfterValidate field to display the Form Events dialog.

  7. Enter the following code and click OK.

    session.invoice_number = invoice_number
    currentform.redirecttarget = "orders.a5w"
  8. Place the dialog component on a page and publish the page (in this case named Pick_Invoice_Number.a5w ).

  9. When you select an invoice number and click Submit, the orders.a5w page will appear.

 After selecting an invoice number on the Pick_Invoice_Number.a5w page and clicking Submit...

 ...the orders.a5w page containing the filtered gridlinker appears.

See Also