TOPIC: Connecting BrowseControl and AccessControl
#1347
Connecting BrowseControl and AccessControl 1 Year, 4 Months ago
I am trying to build a screen that has some tabs. On one of the tabs there should be an AccessControl, on another a BrowseControl. Both controls need to show the same data, except the BrowseControl only as a readonly overview list. However making a selection in the BrowseControl should reflect in the AccessControl and vice versa. I can make the tab book and the controls, but can not get them to connect to each other. According to the help there is something like linkField and headerFields, but I am not sure how to do it. I also studied the AccessBrowseControl (using a flip instead of tabs) but don't see how it is done. Does someone know how it should be done?

Thanks! B)
 
 
#1348
Re:Connecting BrowseControl and AccessControl 1 Year, 4 Months ago
linkField etc. is used to make a browse display records associated with the current Access record, when you have a "master-detail" relationship between two tables. I don't think it'll do what you want.

Here is one half of the solution:

Code:

Window(Controller {
    New()
        {
        .access = .FindControl('Access')
        .browse = .FindControl('Browse')
        }
    Controls: (Tabs
        (Access tables Tab: Access)
        (Browse tables Tab: Browse)
        constructAll:)
    browse: false
    List_Selection(sel)
        {
        if .browse is false
            return
        x = .browse.GetRow(sel[0])
        .access.AccessGoto('table', x.table)
        }
    })



- it is important to use constructAll: otherwise the tabs are constructed lazily (when viewed) which makes it harder

- if multiple rows are selected this code only looks at the first

To do the other half, you could use Access_BeforeRecord(rec) (the access equivalent of List_Selection) and .browse.SelectRow(row)

SelectRow takes a row number, so you have to find the record you want by searching through .browse.GetBrowseData

A lot of this isn't well documented, but you can find most of it by looking at the source code for AccessControl and BrowseControl (and ListControl) in stdlib.

Hope that helps!
 
 
andrew
 
#1349
Re:Connecting BrowseControl and AccessControl 1 Year, 4 Months ago
Great!! Indeed what I was looking for. I am surprised that it takes very little code, I expected some more then that.
I am still a bit puzzled about the constructAll: option. I can what it does when it is removed, but what is the construction behind it? Is it that normally the object is only constructed when the tab is selected by the user?
 
 
#1351
Re:Connecting BrowseControl and AccessControl 1 Year, 4 Months ago
Unless you specify constructAll:, TabsControl only constructs the visible tab. Other tabs are constructed when the user selects them.

The reason for this is that some tabs may be quite slow to construct e.g. if they contain a browse, or rule fields that query a lot of data to come up with their value.

Not constructing them till they are needed speeds things up. Especially in AccessControl, where you want to be able to step through records quickly. To help this, in AccessControl, when you switch records, the non-selected tabs are destroyed (unless you specify constructAll:), so as you step through records, only the visible tab is "running".

Of course, testing, with only small data, you probably won't notice the difference.
 
 
andrew