FILTERS



Node to make filters for a collection. These searches will be shown in the GRID and they can be consulted, deleted or modified according the user´s permissions.

The asfilter node always puts an “and” for the filters, which must be taken into account, in case it could interfere with the filter of the collection. In order to avoid this, we will use parenthesis.


As a point to keep in mind, currently the complex filters are made through special collections.
The steps to follow to make an special collection that has the necessary data, would be as follows:

  • Creation of a collection with no SQL, with thespecial=“true” attribute. This attribute indicates to the machinery that should not search nor give error for not having the SQL field filled in.
  • Making a call to such collection from the appwizard with the mode=“1” attibute, to indicate to show in edition mode after calling it.
  • Within the collection, several props will be put, which will be with the MAP_ in front, in such way that the machinery knows that such fields do not exist in database.
  • In the collection, a content will be created, which will be the collection that has the data that we are really going to visualize. This collection would be the one which should have the asfilter node, if we had made in the simplest way.
  • A button will be put to make the search in the content created to show the data.



ATTRIBUTES
fontsize=“Valor” : It defines the size of the font (in points) that will be shown in the filter.
sort=“true-false” : When the filter is executed, it will order the result by the filtered field (sort=“true”), or it will keep the ordering it was previously (sort=“false”).
left=“Valor” : It indicates the separation or the left margin that the first control of each line will have. .
lines: It indicates the amount of control lines the filter must occupy on screen.



Node where the fields are defined by which a collection can be filtered.

name=“NombreAccion” : It indicates the filter name, it cannot be repeated in the same ASFILTER.
fldname=“Campo” : It indicates the field name of the collection that will be used to filter.
oper=“operacion” : It indicates the condition in SQL format, that is going to make the filter.
width=“Valor” : It indicates the width of the field on screen.
tooltip=“Valor” : This attribute has a text that will be assigned to the tooltip of the control shown on screen when this field is being edited.
newline=“true-false” : It indicates whether the next field of the filter will be or not in a new line.
value=“Valor” : It indicates a value by default that will appear on that field of the filter.
dropcoll=“Coll” : It is used to call to a collection from where the data are taken, and it shows them as a combo.
lmargin=“Valor” : It indicates the left margin gaps which are going to be given to the filter field.
labelwidth=“Valor” : It indicates the label size of the filter field.
type=“N-T -TL | …” : It indicates the type of data in the Database.
applyto=“##MACRO1##”: This attribute when specified has the name of one or several user macros separated by commas.



  <asfilter fontsize="8" left="12" sort="false">
   <field name="TEXTO" fldname="TEXTO" oper="##FLD## LIKE '%##VAL##%'" width="15" tooltip="Ejemplo Texto" newline="false">TEXTO</field>
   <field name="NUMERO" fldname="NUMERO" oper="##FLD## = ##VAL##" width="4" tooltip="Numero Igual a">Número igual a</field>
   <field name="FECHA1" fldname="FECHA" oper="##FLD## &gt;= ##FFVAL##" width="8" newline="false" tooltip="Fecha Inicio">FECHA DESDE:</field>
   <field name="FECHA2" fldname="FECHA" oper="##FLD## &lt;= ##FTVAL##" width="8" newlineX="false" tooltip="Fecha Final">FECHA HASTA:</field>
   <field name="NUM1" fldname="NUMERO" oper="##FLD## &gt;= '##VAL##'" width="8" newline="false" tooltip="Número desde">Num.Desde:</field>
   <field name="NUM2" fldname="NUMERO" oper="##FLD## &lt;= '##VAL##'" width="8" newline="false" tooltip="Numero hasta">Num.Hasta:</field>
   <field name="NOMBRE" fldname="MAP_NOMBRE" oper="##FLD## like '##VAL##%'" width="15" dropcoll="ColeccionAMostrar">Lista</field>
   <field name="MAP_BIT" fldname="MAP_BIT" type="N" oper="##BIT##(##FLD##,##VAL##)" width="2">OPCION1(1) o OPCION2(0):</field>
  </asfilter>


Leaving the previous code as it is, and now we are going to comment the play one by one, or two by two in the case of date from and data up or number from and number up.
It is necessary to mention, besides, that for the dates we always use datetime and that for the FTVAL and FFVAL macros, what they do is adding the time to the search field.

Checking if the single quotes are ok when we compare with ⇐ o >=.

For the line of the dropcoll, just especfy what is done when there are few values in the collection called, if there are many a normal text search field is put.

We also give an example about filtering NC fields “multi-purpose” of those who are worth in PDA and everywhere.

We also comment that if we want to filter by a field from another collection, we will filter by the MAP_LOQUESEA, the IDLOQUESEA for the user as if it did not exist.

These are the fields by which we can filter: text, numeric, real, NC, field MAP_ linked from another collection and datetime.
For instance, it cannot be filtered by a photo field of PDA, for this, we can search anohter solutions that are not so immediate. For the previous example, we would put a field that the user cannot see ( visible=0 ),that would have value 1 when the onchange node of the photo field will be executed.

Notes:

1.- In somefield are the newlineX=“false” or Xnewline=“false” attributes. To skip an attribute, in many times we put an 'X' at the beginning or at the end of the attribute and this way the machinery does not detect it as a valid attribute and it DOES NOT take it into account.

2.- At the oper attribute there are characters such as '&lt;' or '&gt;' or '%'.

  1. '&lt;' and '&gt;' it translates into xml by '<' and '>' respectively.
  2. '%' is equal than the SQL sintax of the like:
    • If '%##VAL##'is put at the beginning, it is translated by: that ends with…
    • If '##VAL##%'is put at the end, it is translated by: that starts with …
    • If '%##VAL##%'is put at the beginning and at the end, it is translated by: that contains…


At the asfilter different macros can be used, such as:

##FLD##: It is used in the oper attribute and it takes the value of the field there is in the name attribute, that is the field by which we are going to make the query.
##VAL##: It is used in the oper attribute, it takes the value that the user puts in the search field.
##FTVAL##: It is used in the oper, and it is to search dates, it is for the ⇐ to the entered value.
##FFVAL##: It is used in the oper, and it is to search dates, for the >= to the entered value.
##TODAY##: It takes as value the current date of the system.
##LASTMONTHDAY##: It takes as value the last day of the month.
##FIRSTMONTHDAY##: It takes as value the first day of the month.
##BIT##: It takes the necessary bit. It only can be used in the PC framework.




filtro1.jpg

We fill in the filter and we click into the MAGNIFYING GLASS.

filtro2.jpg

We fill in the filter and we click into Search or “Enter”.

filtro3.jpg

We fill in the filter and click onto the MAGNIFYING GLASS.

    <prop name="BTNBUSCAR" type="B" title="Buscar" group="1" visible="1" method="ExecuteNode(buscar)" />
    <buscar>
        <action name="runscript">
            <script language="VBScript">
                This("MAP_CODIGO") = Replace(This("MAP_CODIGO"), "'", "")
                This("MAP_NOMBRE") = Replace(This("MAP_NOMBRE"), "'", "")
                This.Contents("NombreDelContent").filter="CODIGO LIKE '%" + This("MAP_CODIGO") + "%' AND NOMBRE LIKE '%" + This("MAP_NOMBRE") + "%'"
	    </script>
        </action>
    </buscar>

Notice that we have removed the quotes to avoid that the user may break the SQL by putting them and leave the door open to SQL injection attacks.

Save the previous filter if necessary, so we are replacing to the previous one.