Using the RapidSearch Technique with Tabpanels

Questions, tips and tricks and techniques for scripting in Servoy

Using the RapidSearch Technique with Tabpanels

Postby xtsr » Mon Jan 26, 2004 11:19 pm

I successfully used the "RapidSearch" technique in my solution (http://forum.servoy.com/viewtopic.php?t=611 - thanks Matt!).

Now I tried to use the same technique when I'm on a form and want to display the result of the search in a tabpanel on the same form, but it didn't work. First I get a "cannot save form data" error, saying "Duplicate entry '0' for key 1" (i don't want to create any record!). When I try again, I get "Search failed... try show all". Performing the search on the form which is displayed in the tabpanel works fine.

What I want to achieve is the following. In a global text field I enter the search criteria, hit enter and the search is performed. If I get one record back, this record is selected for further processing, if I find more than one record, the foundset is displayed in a tabpanel. There I click on the record I want the continue working with.
Moreover, when I click on a record in the tabpanel, I would like to display the corresponding picture on the original form. I will probably best use two buttons (select & show picture)?...

What am I missing here? Does it have to do with the relation between the original from and the tabpanel? Would a different approach be more appropriate here?

Thanks!
xtsr
 
Posts: 101
Joined: Wed Jan 21, 2004 11:47 am

Postby david » Tue Jan 27, 2004 5:52 pm

Without going into much detail, here's an idea:

First, you need a form with a tab panel that has two tabs. The first tab is your "one record found" view and shows fields that you want to work on for one record (probably a form). The second tab is your "more than one record found" tab and is a list. For the first tab, you need a self relationship based on the primary key so it only shows the current selected record. For the second tab, use a self relationship based on a constant like the value "1" (create a number column and a calculation that returns 1 with the same name as the number column so that the calculation is stored). This tab will then be able to display any number of records of the table.

When you execute the search, check to see what the maxRecordIndex is. If == 1, then activate the first tab and you are done. If > 1, then activate tab 2 and "transfer" the current found set to the form that is showing in the tab panel:

Code: Select all
//first duplicate the current found set
var dupFoundset = controller.duplicateFoundSet();

//in tab 2, load the duplicated found set
forms.form_tab_2.controller.loadRecords(dupFoundset);


The last thing to do is have a script attached to a row item in tab 2. This script takes you to the related record and activates tab 1.

- david
User avatar
david
 
Posts: 1727
Joined: Thu Apr 24, 2003 4:18 pm
Location: Washington, D.C.


Return to Methods

Who is online

Users browsing this forum: No registered users and 5 guests