Page 1 of 2

(RDMLX) Online Navigation

Posted: Tue Mar 18, 2014 5:58 pm
by soapagent
I have a table bound to SQL Statement that displays data like

2012 10
2013 11
2013 12

This currently goes to a detail form using

#Com_Owner.Set Property('ENTRY_LIST.ONROWCLICK.OPERATION.TYPE') To('OpenForm')
#Com_Owner.Set Property('ENTRY_LIST.ONROWCLICK.OPERATION.NAME') To(BOSSO002)
#Com_Owner.Set Property('ENTRY_LIST.ONROWCLICK.OPERATION.PRESENTMODE') To('Stack')

However, I need to go to a different form depending on the values within each row as each (10, 11 12) has different format. I can't set values at row level because it is bound.

I thought I might be able to point the click event at a script and let the script decide which form to display but I can't see any way of achieving this.

Any ideas?

Re: Online Navigation

Posted: Wed Mar 19, 2014 10:04 am
by Mark_Dale
A suggested approach is to have multiple sub-forms on your target form (BOSSO002), and to hide all the sub-forms except the appropriate one, based on the row data. This could be done by an ECL script that runs when the target form opens. You can hide a subform by setting its height to 0.

(You can't open different forms from the ECl script because the binding context will be lost - the target of the ECL script would not have access to the row data)

Re: Online Navigation

Posted: Wed Mar 19, 2014 10:31 am
by soapagent
Mark
This sounds like the kind of thing I'm after.

The question is on entry to BOSSO002 how do I call script that executes before the page is displayed?

Re: Online Navigation

Posted: Wed Mar 19, 2014 11:09 am
by Mark_Dale
I haven't tried it, but wouldn't it be something like:

#Com_Owner.Set_Op_ExecScript Event('/Form.OnLoad') Resource(Myscript.js)

Re: Online Navigation

Posted: Wed Mar 19, 2014 3:46 pm
by soapagent
I created a copy of LREX0325.js called StudentsOnline.js added it the schema. I've added

Function Options(*DIRECT)
Begin_Com Role(*EXTENDS #LRNG_FORM)

Mthroutine Name(HandleRequest) Options(*REDEFINE)

#Com_Owner.Set_Op_ExecScript Event('/Form.OnLoad') Resource(StudentsOnline.js)

#Com_Owner.Using Element('/Form.Fields')

Case Of_Field(#COM_OWNER.RequestACTION)
.
.


I've refreshed the schema and ran this but the Console remains blank (there is a this.console("... statement.

The syntax looks OK according to the documentation but I can't see any evidence that this is executing.

Re: Online Navigation

Posted: Wed Mar 19, 2014 5:11 pm
by Mark_Dale
Try this:

Instead of specifying:
#Com_Owner.Set_Op_ExecScript Event('/Form.OnLoad') Resource(LREX0325.js)

try:
#Com_Owner.Set Property('/Form.OnLoad.Operation.Type') To(ExecScript)
#Com_Owner.Set Property('/Form.OnLoad.Operation.Resource') To(LREX0325.js)

(This gets around the longrange lansa replacement of '/Form.OnLoad' with '/RunOperation')

Re: Online Navigation

Posted: Wed Mar 19, 2014 6:05 pm
by soapagent
Cheers, that did the trick.

Re: Online Navigation

Posted: Thu Mar 20, 2014 5:59 pm
by soapagent
Having got into the script I need to access the values passed in to the function. These are available within the offline function using SQL binding from the calling function

#Com_Owner.Set_TextBox Name(STUDYR) Layout_Row(1) Layout_Col(1)
#Com_Owner.Set_Binding Name(STUDYR) Property(VALUE) Bindtotype(FLD) Bindto('STUDYR')

#Com_Owner.Set_Binding Name(BOUND_TABLE) Property(ROWLIST) Bindtotype(SQL) Bindto('SELECT ROWID, STDID, CALYR, STUDYR, CRSID, STDMSI, SCHID, SCHLNM, CRSLNM FROM StudentCourses WHERE STUDYR=&(FLD:StudentEntries.STUDYR)

How do I get access to the FLD.STUDYR value?

this.q_getProperty("Form.Fields.STUDYR.Value");

returns null, I guess because the onload happens before the binding is performed.

Re: Online Navigation

Posted: Fri Mar 21, 2014 9:06 am
by tsupartono
When an element is bound to a table, you should access the underlying table directly (as opposed to using the 'Value' property of the element).

From ECL, you can use q_sql to do this.

For example, if I want to get the value of field "SURNAME" from the currently selected table row:

Code: Select all

lrexec(

function()
{
     this.q_sql(''SELECT &(FLD:SURNAME) '', ''scalar'');
},

function(result)
{
     this.console("Value of SURNAME in current context = ", result);
}

);

Re: Online Navigation

Posted: Fri Mar 21, 2014 4:15 pm
by soapagent
Thanks, that worked.