[Openroad-users] Tabpages
FRANK BARRATT
f.barratt at btinternet.com
Thu Oct 25 20:17:16 EST 2007
Bodo,
Thanks, I originally coded it like that but was just trying to do it a bit smarter, I will use the code below for validation, as I dont have that many fields to validate.
Cheers.
Frank.
ON CLICK Chk_btn =
BEGIN
Callproc find_fields_lp(TabPage = FIELD(child_tabs).CurTabPage);
END
PROCEDURE find_fields_lp(TabPage = COMPOSITEFIELD) =
DECLARE
i = integer not null;
ChkField = FIELDOBJECT;
ENDDECLARE
BEGIN
FOR i = 1 TO TabPage.ChildFields.LastRow DO
ChkField = TabPage.ChildFields[i];
IF ChkField.IsA(class = BOXTRIM) = TRUE THEN
/* Do nothing */ ;
ELSEIF ChkField.IsA(class = FREETRIM) = TRUE THEN
/* Do nothing */ ;
ELSEIF ChkField.IsA(class = COMPOSITEFIELD) = TRUE THEN
/* go around again */
Callproc find_fields_lp(TabPage = COMPOSITEFIELD(ChkField));
ELSEIF ChkField.IsA(class = STACKFIELD) = TRUE THEN
/* go around again until we find an entryfield */
Callproc find_fields_lp(TabPage = COMPOSITEFIELD(ChkField));
ELSEIF ChkField.IsA(class = ENTRYFIELD) = TRUE THEN
/*entryfield found */
/* but is it the right one */
IF ENTRYFIELD(ChkField).name = 'myfield' then
/* do the validation on this field */
ELSE
/* we go around again */
Callproc find_fields_lp(TabPage = COMPOSITEFIELD(ChkField));
ENDIF;
ENDIF;
ENDFOR;
END
Bodo Bergmann <Bodo.Bergmann at ingres.com> wrote:
Frank,
as you know that there are only up to 8 tabpages,
why don't you just create a TabFolder (with Declared=TRUE) with 8 tabpages
(with each tabpage already having the fields created and datatype set to your userclass)?
Then make the pages available at runtime by click on the button.
Example.:
initialize()=
declare
i=INTEGER NOT NULL;
lastvis=INTEGER NOT NULL DEFAULT 1;
cust1 = customer DEFAULT NULL;
tabflds_ori = ARRAY OF TabField DEFAULT NULL;
tabflds = ARRAY OF TabField;
tabpages = ARRAY OF TabPage DEFAULT NULL;
enddeclare
{
tabpages = FIELD(field1).tabpagearray;
tabflds_ori = FIELD(field1).TabBar.tabfieldarray;
FOR i=1 TO tabflds_ori.LastRow DO
tabflds[i] = tabflds_ori[i];
ENDFOR;
// Make pages 2 to 8 invisible
FOR i=8 DOWNTO 2 DO
tabpages[i].CurBias = FB_INVISIBLE;
FIELD(field1).TabBar.tabfieldarray.RemoveRow(rownumber=i);
ENDFOR;
FIELD(field1).UpdField();
}
ON CLICK add_btn =
{
IF lastvis<8 THEN
lastvis = lastvis+1;
tabpages[lastvis].CurBias = FB_CHANGEABLE;
tabflds_ori.InsertRow(rownumber=lastvis, rowobject=tabflds[lastvis]);
FIELD(field1).UpdField();
FIELD(field1).CurPageIndex = lastvis;
ELSE
MESSAGE 'Only 8 pages allowed';
ENDIF;
}
ON CLICK check_btn =
{
FIELD(field1).CurTabPage.GetFieldValue(value=BYREF(cust1));
MESSAGE cust1.Name;
}
Bodo.
Bodo Bergmann
Senior Software Engineer
OpenROAD Worldwide Development
Ingres Corp.
---------------------------------
From: openroad-users-bounces at peerlessit.com [mailto:openroad-users-bounces at peerlessit.com] On Behalf Of FRANK BARRATT
Sent: Thursday, October 25, 2007 9:28 AM
To: openroad-users at peerlessit.com
Subject: Re: [Openroad-users] Tabpages
Bodo/All,
That works fine for loading pages into the tabfolder at runtime, but I am looking to use a button so that the user can add their own tabpages (up to 8), using the code below under the button I get a trace error saying that field1 has already been declared, if I undeclare it I lose the data in the first tab and if I don't declare it I get a NULL error on the cust1 userclass.
Thanks again
Frank.
----- Original Message -----
From: Bodo Bergmann
To: International OpenROAD Users
Sent: Tuesday, October 23, 2007 5:45 PM
Subject: Re: [Openroad-users] Tabpages
Frank,
when adding Tabpages dynamically using "AddTabPage" and the page is mapped to a userclass object
then you have to use the DeclareData() method on the TabFolder (not the Tabpage) to assign the value.
The TabFolder should have the "Declared" attribute set to FALSE before.
In the example below the subform "cust" (mapped to "customer" userclas)
is used as a "template" to create a new tabpage:
initialize()=
declare
i=INTEGER NOT NULL;
cust1 = customer DEFAULT NULL;
sf = Subform DEFAULT NULL;
enddeclare
{
i=FIELD(field1).tabpagearray.lastrow + 1;
sf = FIELD(cust).Duplicate();
sf.Name = 'page'+varchar(i);
sf.AllBias = FB_CHANGEABLE;
FIELD(field1).AddTabPage(subform = sf, tabtext = 'Page '+varchar(i), pagenum = i);
FIELD(field1).DeclareData();
}
ON CLICK check_btn =
{
FIELD(field1).CurTabPage.GetFieldValue(value=BYREF(cust1));
// Now check attributes using cust1 reference, e.g. "cust1.Name"
}
Hope this helps,
Bodo.
Bodo Bergmann
Senior Software Engineer
OpenROAD Worldwide Development
Ingres Corp.
---------------------------------
From: openroad-users-bounces at peerlessit.com [mailto:openroad-users-bounces at peerlessit.com] On Behalf Of FRANK BARRATT
Sent: Tuesday, October 23, 2007 3:45 PM
To: International OpenROAD Users
Subject: Re: [Openroad-users] Tabpages
Bodo,
I cannot find a way to map a tabpage to a userclass only the tabfolder or subform.
So when i call curtab = FIELD(my_tab).CurTabPage method,
I try to access the attribute values of curtab but it only has the childfields attribute as it does not know about my userclass object.
For my default page 1 can access the field values with mytab.page1.mysub.myfield.
For subsequent pages i need mytab.page1.curtab.myfield.
Now amount of casting and using the mysub userclass has resulted in obtaining the myfield values, thats why i have used the curtab.childfileds array.
Is there a way to create a tabpage from a userclass, or am i having a stupid day.
Regards
Frank.
Bodo Bergmann <Bodo.Bergmann at ingres.com> wrote:
Hi Frank,
as your TabPage is mapped to a userclass object anyway,
why don't you just validate the according attribute values of this object
(or the objects, if each tabpage is mapped to a different userclass object) ?
Bodo.
Bodo Bergmann
Senior Software Engineer
OpenROAD Worldwide Development
Ingres Corp.
---------------------------------
From: openroad-users-bounces at peerlessit.com [mailto:openroad-users-bounces at peerlessit.com] On Behalf Of FRANK BARRATT
Sent: Tuesday, October 23, 2007 2:19 PM
To: openroad-users at peerlessit.com
Subject: [Openroad-users] Tabpages
Hi,
I am dynamically creating tab pages on a tabfolder using this
FIELD(my_tab).AddTabPage(subform = FIELD(mysub),tabtext = 'Page ' + varchar(FIELD(my_tab).tabpagearray.lastrow + 1),pagenum = FIELD(mytab).tabpagearray.lastrow + 1);
mysub is a hidden subform based on a userclass containing lots of fields and is the same for each tabpage.
At the moment i get the current field values for validation by the
curtab = FIELD(my_tab).CurTabPage method.
I then loop through the curtab.childfields to get my field values.
My question is there an easier way of accessing the field values from my dynamic tabs without looping through the childfields array as this is getting a bit messy.
Thanks in advance.
Frank.
________________________________________________________________
OpenROAD-Users mailing list
You can maintain your subscription here:
http://www.peerlessit.com/mailman/listinfo/openroad-users
To unsubscribe click on this link
mailto:openroad-users-unsubscribe at peerlessit.com&subject=unsubscribe
To subscribe click on this link
mailto:openroad-users-subscribe at peerlessit.com&subject=subscribe ________________________________________________________________
OpenROAD-Users mailing list
You can maintain your subscription here:
http://www.peerlessit.com/mailman/listinfo/openroad-users
To unsubscribe click on this link
mailto:openroad-users-unsubscribe at peerlessit.com&subject=unsubscribe
To subscribe click on this link
mailto:openroad-users-subscribe at peerlessit.com&subject=subscribe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.peerlessit.com/pipermail/openroad-users/attachments/20071025/df9288f6/attachment.html
More information about the Openroad-users
mailing list