Problem with grid and datasource

Posted by Elena_Perello on 27-Feb-2012 03:26

Hi!

I've this method:

METHOD PUBLIC LOGICAL ctmCreaQuery(input v_htt as handle):

DEFINE VARIABLE v-hq AS HANDLE NO-UNDO.

DEFINE VARIABLE v-buftt AS HANDLE NO-UNDO.

DEFINE VARIABLE v-aux AS INTEGER NO-UNDO.

DEFINE VARIABLE PBS-datos AS Progress.Data.BindingSource NO-UNDO.

IF VALID-HANDLE (v_htt) THEN v-buftt = v_htt:DEFAULT-BUFFER-HANDLE.

IF VALID-HANDLE (v-hq) THEN

DO:

v-hq:QUERY-CLOSE ().

DELETE OBJECT v-hq.

END.

CREATE QUERY v-hq.

v-hq:SET-BUFFERS (v-buftt).

v-hq:QUERY-PREPARE ("FOR EACH " + IF VALID-HANDLE (v_htt) THEN v_htt:NAME ELSE v-tablawhere).

v-hq:QUERY-OPEN ().

IF VALID-OBJECT (PBS-datos) THEN DELETE OBJECT PBS-datos.

PBS-datos = NEW Progress.Data.BindingSource (v-hq, P_BDTTcampos, P_BDTTquitarcampos).

ASSIGN

PBS-datos: HANDLE = v-hq

PBS-datos:AllowEdit = FALSE

PBS-datos:AllowRemove = FALSE

PBS-datos:AllowNewFALSE

.

/* asigna el bindingsource al grid */

ctmGrid1:DataSource = PBS-datos.

ctmgrid1:Refresh().

RETURN YES.

END METHOD.

The problem is that the first time I call the method does well, but if you call back for me to load the grid with another condition I did not do well. If I load the records, but not painted on the grid.

1.png

2.png

All Replies

Posted by WJCPvanBeek on 08-Mar-2012 08:23

Hi Elena,

First of all. You should define variable v-hq outside of your method. The way you defined it v-hq will never be valid, because it has just been defined. Moreover you have a memoryleak, because you cannot delete the dynamic query that was in this variable anymore.

The same applies to variable PBS_datos. Define it outside the method.

I cannot see what the contents of v-tablawhere is, but are you sure it starts with the name of the buffer ?

Best Regards and succes,

Will

This thread is closed