Page 2 of 4

Re: Filtro con varios campos./Filter multiple fields.

Posted: Thu Apr 03, 2014 5:37 pm
by Javier Tovar
serge_girard wrote:Javier,


You can call Limpia with a button in order to reset your filters.

Serge
Buena idea! :D :D :D

Saludos

Re: Filtro con varios campos./Filter multiple fields.

Posted: Thu Apr 03, 2014 6:32 pm
by Javier Tovar
Hola a todos,

Ya probe con el código de serge_girard y si funciona bien para campos no consecutivos, pero no se que pasa que en ocasiones no selecciona el campo deseado y en su lugar pone un registro en blanco? por que será?

Ya reindexe y sigue igual.

Alguna idea?

P.D.: Aparte de las anteriores dudas.
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////



Hi all,

Since the probe serge_girard code and if it works well for nonconsecutive fields, but that does not happen that sometimes you do not select the desired field and instead gets a blank record? that will be?

Now reindex and still the same.

Any idea?

P. D.: Apart from the above doubts.
ERROR.jpg
ERROR.jpg (125.44 KiB) Viewed 2421 times

Re: Filtro con varios campos./Filter multiple fields.

Posted: Thu Apr 03, 2014 7:40 pm
by serge_girard
Javier,

Try to make to same selection but USE the files WITHOUT indexes, then see if you still get an empty record in grid_2.
Following the code there is 1 record that meats the selection (total items:1) but the index-record pointer is probably at eof(). So try without indexes.

If you need to show the recors in a special order you can sort them afterwards. Simple code which I can supply if you want.

Greetings and succes!

Serge

Re: Filtro con varios campos./Filter multiple fields.

Posted: Thu Apr 03, 2014 7:47 pm
by serge_girard
Javier,

While testing I discovered the same you had: empty record 0. But when focusing on my browser and then coming back to the program... it suddenly was visible. Now I will find the reason and will let you know.

Serge

Re: Filtro con varios campos./Filter multiple fields.

Posted: Thu Apr 03, 2014 8:00 pm
by serge_girard
Javier, It must be the indexes. I removed all indexing and recompiled and no problemo....!

Success, Serge

Re: Filtro con varios campos./Filter multiple fields.

Posted: Thu Apr 03, 2014 8:01 pm
by Javier Tovar
serge_girard wrote:Javier,

Try to make to same selection but USE the files WITHOUT indexes, then see if you still get an empty record in grid_2.
Following the code there is 1 record that meats the selection (total items:1) but the index-record pointer is probably at eof(). So try without indexes.

If you need to show the recors in a special order you can sort them afterwards. Simple code which I can supply if you want.

Greetings and succes!

Serge
OK serge_girard,

Now you remove the index to Zapatos1 and already responds well!, Boy try ordering!

thanks

Re: Filtro con varios campos./Filter multiple fields.

Posted: Thu Apr 03, 2014 8:21 pm
by Javier Tovar
serge_girard wrote:Javier,

If you need to show the recors in a special order you can sort them afterwards. Simple code which I can supply if you want.


If you have at hand and sort records, would be nice, I thought the customer what they need is sorted by!:

-Type-Brand-Model-Color-Finish

For the simplest serious because so accustomed to. And so is not lost on the grid.
thanks

Re: Filtro con varios campos./Filter multiple fields.

Posted: Thu Apr 03, 2014 9:08 pm
by Javier Tovar
serge_girard wrote:Javier,

Try this, it can take many selections:

Code: Select all

PROCEDURE Selecciona(nCampo)

....

Filter := {}

IF !EMPTY(c1)
   AADD(Filter, {|| Zapatos->(Tipo) == c1})
ENDIF

......

DO WHILE .not. eof()
   IF EvalFilter()
      Zapatos1->(DBAPPEND())
      Zapatos1->Codigo := Zapatos->Codigo
      Zapatos1->Tipo   := Zapatos->Tipo
      Zapatos1->Marca  := Zapatos->Marca
      Zapatos1->Modelo := Zapatos->Modelo
      Zapatos1->Color  := Zapatos->Color
      Zapatos1->Acabado:= Zapatos->Acabado
   ENDIF

.......

STATIC FUNCTION EvalFilter()
****************************
LOCAL retval := .T.
LOCAL i

FOR i := 1 TO LEN(Filter)
   retval := retval .AND. EVAL(Filter[i])
NEXT


RETURN retval
[/quote]

Mi primera impresión es que si funcionaba, pero no entendía lo que hacia este código, después de investigar un rato ya vi como funciona. Ahora si que aplico la del folósofo "Yo sólo sé que no sé nada"!  ;) 

Muy Interesante!  :o 

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

My first impression is that if it worked, but did not understand what made this code, after researching a while since I saw how it works. Now if I apply the the folosofo "I just know that I know nothing"!  ;) 

Very interesting!  :o 

Saludos

Re: Filtro con varios campos./Filter multiple fields.

Posted: Fri Apr 04, 2014 8:53 am
by serge_girard
Javier,


I made some changes:

- Filling the grids is now done by ADD ITEM. Advantage is that you can sort them AND you don't need the database. So SELECT database, fill grid and close database.
- Sorting the grids by clicking on the head of the grid

See attachment !

Greetings, Serge

Re: Filtro con varios campos./Filter multiple fields.

Posted: Fri Apr 04, 2014 9:26 pm
by Javier Tovar
Hola serge_girard,

Excelentes ejemplos me has mandado!, esa era mi pregunta, Yo lo hago así, pero ustedes con mayor experiencia como lo hacen? y no cabe duda que la codificación es muy diferente y claro más versátil y clara, me gusto!.

Felicidades y mil gracias! :D :D :D

Saludos!

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Hello serge_girard,

Excellent examples you sent me!, That was my question, I do so, but more experience you do? and there is no doubt that the coding is very different and more versatile light and clear, I like!.

Congratulations and many thanks! :D :D :D

Greetings!