Simplicty and flexibility!


DataEase 8.2 - "New" function(s) SelectionFilter() (add or) (Ver. 8.2.0.1600)

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

DataEase 8.2 - "New" function(s) SelectionFilter() (add or) (Ver. 8.2.0.1600)

Download Sample

When you "rebuild " a 20 year old product like DFW, you come across a lot of history. A lot of good ideas that never was completed, a lot of brute work with complete lack of finesse, lazy work and complete lack of understanding.

So much as been implemented in this product that was never promoted, finished, documented or even used.

A lot of the "good" ideas was abandoned because they were released to early and was completely buggy so people was scared off.

It is no secret that moving to new versions of DFW was considered a risky business so it became almost a matter of professional conduct to keep things running in the oldest version possible. Needless to say, this is a serious issue for a company like us, so we have made it our goal that every new version should be better than the last. Not only in functionality, but also in stability and compatibility!

Through our DG3 project we harvest a lot of experience on how modern web based applications work, and we want to allow DFW users to build application very much along the same guidelines.

Functions like SetStyle()/GetStyle(). SetState(), SetFocus() etc. is ideas picked up through this.

In DG3 you basically don't use fixed relationship for navigation, but ad-hoc generated Queries that is passed through the URL. This allow for a mcuh more flexible approach and we want to allow DFW user to do the same.

OpenRelated() is a powerful function, but the problem is that the Query is "fixed" so when you have used Open Related  you can't change the Query (expand) from within the form. 

What Open Related in reality do is to set the filter for the data, but it is a filter that you cannot override.If you instead set this filter yourself, you can reset it , AND it (add to it) or OR it etc. 

The main function in question is SelectionFilter().

The syntax for SelectionFilter is:

SelectionFilter(String,String) and it has been a mystery how to create this filter. Logic will say that you have the column in the first string and what it is suppose to be equal to in the second, but what if it is greater or smaller to?

There is no pre-existing help on this function but luckily we have the source code so we could look at it from within.

In reality the double string is a "lure", they are both simply concatenated together into one string and this string simply need to have a valid syntax.

A valid syntax would for a number field be: CustomerNr=1 and this would be represented very easily by executing: SelectionFilter("CustomerNr=","1") , so what is the big fuss?

The strength of DataEase filtering only really show its power when you start doing text searching and especially wild card search.
So what is the syntax for searching in a text field?

Normal DataEase derivation syntax which is: CustomerName="British Airways" and now you realise the trouble with doing this filtering...

Pre DE8 there would be no realistic way of doing this. In DE8.0 you would do:
SelectionFilter("CustomerName=",concat(chr(34),"British Airways",chr(34))) and this is what we have been doing up till now.

From 8.2 onwards you simply do this:

SelectionFilter("CustomerName=","/'British Airways/'").

Simples.

But why bother using this function?



define "retval" text .

if GetVar("SokeFelt") not=blank then

retval := SetStyle(concat("label",GetVar("SearchField")),"Blue") .

retval := SetLabelText(concat("label",GetVar("SearchField")),GetVar("SearchField")) .

retval := SetVar("SearchField","Address") .

retval := SetStyle(concat("label",GetVar("SearchField")),"Red") .

retval := SelectionFilter(GetVar("SearchField"),concat("=",chr(34),GetVar("SokeFelt"),"*",chr(34))) .

retval := SetLabelText(concat("label",GetVar("SearchField")),concat(GetVar("SearchField")," - (Search: ",GetVar("SokeFelt"),")")) .

else

retval := SetStyle(concat("label",GetVar("SearchField")),"Blue") .

retval := SetLabelText(concat("label",GetVar("SearchField")),GetVar("SearchField")) .

retval := SetVar("SearchField","Address") .

retval := SetStyle(concat("label",GetVar("SearchField")),"Red") .

end .

Here is the answer. This is the code on Clicked event on labelAddress in the sample, and there is similar code on each label. Click on them and see the effect?

Here we change the field we search on with the same search value simply by clicking and setting filter.

You could of course narrow down the search the same way by using AddFilterAnd() and AddFilterOr()...


Written by DataEase 18/08/14 at 18:49:50 Dataease [{8}]FIVE