Easy to Create, Easy to Change - Easy to use!

New Sample - CTRL-F10 Simulation with automatic search

Started by DataEase
You will need to Sign In to be able to comment on the Blog!

New Sample - CTRL-F10 Simulation with automatic search

Download Sample!

This is just a small sample that show how you can use subforms as an alternative to built in lookup and search alternatives. 

Both Multibox and CTRL-F10 is quite limited so we want to visualise how you can use the new (and some old) features to get exactly what you want rather than be stuck with some of DataEase Developments less proud moments...

As before we take advantage of a support field (relkey) and a subform that we hide and show.

In this example we basically search in customer names, and after the drop down is displayed you can change or narrow down the search.

the code to look for is the OML code on the Company fields KeyDown event.

define "retval" text .

message KeyValue .

if KeyValue=13 then

retval := SetState("Pick",4) .

Here we use the return value from event KeyValue and this bring us onto a quite "undiscovered" part of DataEase OML, 

Read more here..

As you see from the script above we call SetState("Pick",4) which interprets as ClickEvent on pick button, this is because there is problems with triggering the Re-Read of the Subform when you set the value from OML (being investigated) but this workaround is fine.

To put code on Buttons and then call them via SetState(4) is quite a nifty way of re-using code as you can put it at the end of other script to do default execution.

Written by DataEase 02/12/14 at 13:23:18 Dataease [{8}]FIVE

Re:New Sample - CTRL-F10 Simulation with automatic search

This is a rather "technical" sample that is getting old now, and it was more meant as inspiration to a technical thinking around functionality in DataEase 8 than a practical way to solve this problem. 

But nothing wrong in explaining it a little better:

The subform is crated on the virtual field RelKey. This field contain a derivation that simply states: "a*".
This means that the initial display in the "dropdown" is a list of customers that start with a.

We also hid the subform with SetState("Jumbled",0) -- name of subform and hide (0).

We are ready to start.

When you key something into the Company Field nothing happens, until you hit enter or click on Pick button.

When you hit enter we have a listener on the KeyBoard event on Company so when it gets 13 (enter) it will simply click the button Pick to save some codeing (SetState("ObjectName","Click")).

On the button we simply push the value of the field Company concatenated with a *. As this field is a relationship key that the "dropdown" (subform) is dependent on it will force the subform to reload data and we will get the values that is correct for the new relationship hit.

At the same time we "show" the dropdown with SetState("Jumbled",1).

Now everything is ready for us to pick a value.

And then we hide the "dropdown" again wtih SetState("Jumbled",0)

See that we use a virtual field in the Subform that is just derived from the actual column (vCustomerName). This is because we want the field to be write protected so we can click on it without entering into edit mode.

On the Clicked event we simply run a plain SetValue() to set the value back into the Comany field and then hide the dropdown.

Hope this helps.

Written by DataEase 01/03/16 at 16:52:33 Dataease [{8}]FIVE