View Full Version : Overriding settings in GridLinker Component


Howard G. Cornett
10-09-2004, 10:37 AM
How do you override settings in a Grid Component in a GridLinker Component? I tried using the method for Grid Components themselves, and I can't get it to work. Am I doing something wrong? Is it not possible? How can I do this?


Selwyn Rabins
10-10-2004, 09:40 AM
yes it is possible.

all of the examples the sample web app demo do it. in most cases they just set the component name. but in some cases they set other properties as well.

open any of the .a5w pages in the sample demo in the HTML editor, or in notepad. switch to source view.

you will see code like this:

with "variablename"
componentName = somename
end with

in this block of code you can override any of the component's settings.

the ability to override settings is a very powerful feature of components because it allows you to design one component, but then use it in many different ways.

also, it allows you to dynamically set component properties at runtime using xbasic. this is an exceptionally powerful feature.

Pat Bremkamp
10-12-2004, 04:29 PM

Your description works great in a page with a single component, but I think the question referred to a GridLinker component. The only example of that in the demo is Orders_wItems, and it does not have a "with...." section.

I have tried various ways to use the override in a gridLinker, but I can't figure out how to address the individual component. In one page with a parent and a child, A5 writes the follwing:

Delete tmpl_GridLinker
DIM tmpl_GridLinker as P
tmpl_GridLinker = a5w_load_component("Entity_Security")
'======compute the HTML for the Component================
delete x_GridLinker
dim x_GridLinker as p
tmpl_GridLinker.request = request
tmpl_GridLinker.session = session
tmpl_GridLinker.response = response
tmpl_GridLinker.serversetting = serversetting

I have tried tmpl_Gridlinker.parentcomponentname and I've tried x_GridLinker.parentcomponentname, but neither one seems to work.

How do you address, for example the parent component in a linked grid?


Selwyn Rabins
10-13-2004, 12:01 PM
Overriding settings a GridLinker component at run-time is not as simple as it is for a Grid or Dialog component.

That's because a lot of the code that executes is hidden inside the defintion of the GridLinker component.

Nevertheless, once you understand more about what goes on inside the GridLinker component, it is not that hard to do.

The first step is to make sure you know what the aliases are for each of the Grid components in the GridLinker.

To find the names of the aliases, you will need to edit the GridLinker, go to the 'Select & Link' tab and click the Edit button. A dialog will open telling you what the alias is for each component in the GridLinker.

For example, let's look at the sample 'Orders_wItems' GridLinker component that is part of the sample web application that ships with Alpha Five. This component links the 'OrderHeader' and 'InvoiceItems' Grid components. In this case the internal alias names used for each component is the same as the component name, but it need not be.

Let's assume that at run-time we want to change the OrderHeader component so that it only displays 3 rows of data.

If you look at the code in the .A5W page that runs the 'Orders_wItems' component, you will see code that looks like this:

Delete Tmpl
DIM Tmpl as P
tmpl = a5w_load_component("Orders_wItems")

After the component has been loaded, the pointer variable 'tmpl' contains the definition of the GridLinker. This pointer variable has an internal property array called 'Grid_Info' that contains information about each of the linked Grids. This property array has a property called 'OverrideSettings' which contains the Xbasic necessary to overrride settings for any Grid in the GridLinker.

So, for example, if the GridLinker links 4 different Grid components, the tmpl pointer variable will have a sub-array with four entries - one for each Grid. The problem is that you don't know which entry in the array corresponds to which Grid, so you have to execute some Xbasic to find the appropriate entry in the array.

The following example show how this can be done:

'find the entry in the tmpl.grid_info[] array for the component with the alias 'OrderHeader'
dim indx as n
indx = tmpl.grid_info.find(ut("orderheader"),"ut(componentalias)")
'if indx " 0 then a match was found
if indx " 0 then
with tmpl
With Grid_Info[1]
.OverrideSettings = ""%code%
rows = 3
end with
end with
end if

This code gets places immediately after the code that loads the component. I.e. after this line:

tmpl = a5w_load_component("Orders_wItems")

John Haytko
10-16-2004, 11:45 AM

Would this advice apply in the case of trying to filter the parent of a gridlinker with a WAS session variable?



Selwyn Rabins
10-18-2004, 06:45 AM