In certain situations there may be a need to create a lookup with data filter and/or return various information.


Let's study the frmCadCLIENTES example.




Access frmCadCLIENTES, COMMERCIAL tab, to follow the explanation of the ONCLICK and ONENTER event code.




The ONCLICK event code will be dynamically associated with the ONCLICK of the search BUTTON that will be created in RUNTIME.


The procedure rc_LookUpSearchFilter passes to RadCORE the information to search for "CUSTOMERS" since the "CURRENT CUSTOMER( record )" is not displayed and passes a list of fields that can be used for both search and return, that is, we pass a parameter with a "WHERE" to filter the search that will be carried out by the lookup.


After the search selection is done, it is tested if the record is being edited so we call the rc_GetLookUpField function to fill in the data we need.


As the lookup search QUERY/DATASOURCE is dynamically created, this function is used to access this query and its respective field.


Feeding a lookup in return


If you need to return information to also feed a lookup, you must add the field to the list of "rc_LookUpSearch" and use the commented lines as a reference.


In the case of BAIRRO ( just a possible example of use ), as this field is also a LOOKUP, we associate CODIBAIRRO ( primary key code ) and update the lookup so that it can be filled with its respective description ( rc_LookUpUpdateData ).





The code for the ONENTER event was added because in the example we are studying, the CUSTOMERS LOOKUP will also display the search for the customer code, so when entering a code we need to update the data, because as soon as the lookup is it loses focus , triggers ONENTER.


DISPLAYING AUTOMATIC RETURN VALUES


A common need is to display a return value from a display-only lookup, that is, it won't be edited, but you can save the value to the database - if you need to.


In this case, we have one more possible variation in the formation of the lookup 'syntax':


edLkpTABELA_SetDS_FIELDNAME



See the image below:




When selecting a CITY in edLkpCITIES, the "IBGE Code" field is automatically updated WITHOUT ANY code.


The same condition used in the ONCLICK of the LOOKUP of the account is taken advantage of.


When creating a field with the _SETDS suffix, RadCORE will dynamically associate the DATASOURCE that was created exclusively for this LOOKUP, making it easy to display.


It is possible to save the return of "setds" by adding the following pseudo-command in the HINT property:


[[saveto:field]]


"field" is the name of the field in the destination dataset that will receive the content.


Informing only "saveto:" without an explicit "field", RadCORE assumes that, in the destination table, there is a field with the same name as the source table, that is, if we set:


edLkpCIDADES_SetDS_CODIIBGE with [[ saveto: ]]


is why there is a field named "CODIIBGE" to save the return.




Created with the Personal Edition of HelpNDoc: Full-featured Help generator