TOPIC: BrowseControl filtered by a Field
#1762
BrowseControl filtered by a Field 8 Months, 1 Week ago
Hi!!!, I want to build a BrowseControl and filter it by a field or Columns. I was reading the manual, but I didn't found nothing. Somebody can send me an examples. Thanks very much.

Hola. Quiero construir un BrowseControl y filtralo por un campo or columna. Estuve leyendo el manual, pero no encontré nada. Alguien puede enviarme un ejemplo. Muchas Gracias.

My tables is:

trprovincia
(
paiscod,
codprov
provincia,
sintetico
)

field_paiscod
{
//id_control
}
 
 
#1763
Re:BrowseControl filtered by a Field 8 Months, 1 Week ago
Why you don't do it when passing a query to BrowseControl:

queryStr = "anyTableToQuery where someField = " $ Display(somevalue)

BrowseControl(queryStr)
 
 
#1764
Re:BrowseControl filtered by a Field 8 Months, 1 Week ago
Please Look at the attached File. Each time the user selected an item (paiscod), I want to retrieve again the data in BrowseControl. Is It possible to do it, with your tip?. thanks.

Por favor mire el archivo adjunto. Cada vez que el usuario seleccione un item(paiscod), Quiero recuperar de nuevo los datos en el BrowseControl. ¿Es posible hacerlo con su sugerencia?. Gracias.
 
 
#1765
Re:BrowseControl filtered by a Field 8 Months, 1 Week ago
Sorry. I forgot the attached file
File Attachment:
File Name: BrowseControl_Filtered_by_field.zip
File Size: 16638
 
 
#1824
Re:BrowseControl filtered by a Field 7 Months, 1 Week ago
Hi!!!. Please somebody can send me an example?. Thanks.
 
 
#1825
Re:BrowseControl filtered by a Field 7 Months, 1 Week ago
I think you'll need to use BrowseControl's SetQuery method. Here is a very simple example:

Controller
{
Controls: (Vert
(Field name: 'test')
(Browse ''))

NewValue(val, source)
{
if source is .Vert.test
{
.Vert.Browse.SetQuery("tables where tablename =~ " $ Display(.Vert.test.Get()))
}
}
}

When you tab out of the field the browse will be set to all tables in the database where the table name matches the field value.
 
 
Last Edit: 2010/01/13 16:33 By jferguson.
 
Jeff Ferguson
Suneido Software
 
#1826
Re:BrowseControl filtered by a Field 7 Months, 1 Week ago
I forgot to mention that you would also want to call BrowseControl's Save method before calling SetQuery if you want the users changes to be saved before resetting the browse.
 
 
Jeff Ferguson
Suneido Software
 
#1833
Re:BrowseControl filtered by a Field 7 Months, 1 Week ago
jferguson: Thanks for your Answer. I wrote the next code, but I don't know how to set the title. Can you help me please?. Thanks again.

Gracias por su respuesta. Escribí el siguiente código pero no sé como establecer el titulo. ¿ Puede ayudarme por favor?. Gracias de nuevo.

/* ----------------------------------------------------------*/

/* Permite realizar el ABM (A=alta, B=Baja, M=mdoficación) de las provincias

*/

Controller

{

Controls: (

title: 'ABM de Provincia'

Vert

//PassthruController

Provincia

(Browse 'trprovincia'))



// Cada vez que se selecciona un nuevo item en el control provincia se dispara este método.

NewValue(val, source)

{

//Graba los datos antes de recuperar los nuevos datos, para el código de país seleccionado

.Vert.Browse.Save()



// Recupera los datos, filtrados por código de país

.Vert.Browse.SetQuery("trprovincia where paiscod = " $ Display(val))



// Verifica que el control tenga filas

if .Vert.Browse.GetCurrentRecord() > 0

{

// Establece por el código de país seleccionado en el control Provincia.

.Vert.Browse.SetField('paiscod', val, .Vert.Browse.GetCurrentRecord(), false)

}

}

}
 
 
#1834
Re:BrowseControl filtered by a Field 7 Months, 1 Week ago
Change this:
Code:


Controller
{
Controls: (
title: 'ABM de Provincia'



By this:

Code:


Controller
{
//Variables with uppercase letter outside methods override the ones on parent class
Title: 'ABM de Provincia'  
Controls: (

 
 
#1840
Re:BrowseControl filtered by a Field 7 Months ago
Thanks a Lot.