Please help with row colouring in dynamic browse

Beeb

Member
Hello All,

I have a problem with the colouring of certain rows in a dynamic browse.
I’ll show what I have got:

/*********************** PROCEDURE to build the browse**********************/
CREATE BUFFER table-name FOR TABLE "tt_productie".
CREATE QUERY dyn-query.

CREATE BROWSE dyn-browse-prod
ASSIGN WIDTH = 71
HEIGHT = 12
EXPANDABLE = FALSE
COLUMN = 1
ROW = 1
FRAME = FRAME frm_prod:HANDLE
READ-ONLY = TRUE
SENSITIVE = TRUE
SEPARATORS = TRUE
ROW-MARKERS = TRUE
VISIBLE = TRUE
COLUMN-RESIZABLE = TRUE
TRIGGERS:
ON ROW-DISPLAY PERSISTENT RUN prodCol.

ON LEFT-MOUSE-CLICK PERSISTENT RUN reposPers(INPUT "prod").

ON 'RIGHT-MOUSE-CLICK' PERSISTENT RUN rightProd.
END.


/* attach the query to the browser */
dyn-browse-prod:QUERY = dyn-query.
/* query value is the string which will be used to open the query */
query-value = "For each tt_productie by dept by part by machine"
/*where dwpdc_mstr.dwpdc_date >= 19/03/2007"*/.

/* prepare and open the query */
dyn-query:QUERY-PREPARE(query-value).


ASSIGN v_list = "tt_productie.keynr,tt_productie.dept,tt_productie.machine,tt_productie.tiknr,tt_productie.action,tt_productie.prodtijd,tt_productie.prodstil,tt_productie.totaal".

DO cntr = 1 TO NUM-ENTRIES(v_list, ","):
col-handle = dyn-browse-prod:ADD-LIKE-COLUMN(ENTRY(cntr,v_list, ",")).
col-handle:READ-ONLY = TRUE.
IF cntr = 1
THEN col-handle:VISIBLE = FALSE.

ASSIGN v_collist[cntr] = col-handle:HANDLE.

CASE cntr:
WHEN 2 THEN col-handle:WIDTH = 6.
WHEN 3 THEN col-handle:WIDTH = 13.
WHEN 4 THEN col-handle:WIDTH = 7.
OTHERWISE col-handle:WIDTH = 8.
END CASE.
END.

dyn-query:QUERY-OPEN().

APPLY "home" TO dyn-browse-prod.
END PROCEDURE.


In the row-display trigger of the browse I want to colour certain rows depending on a value in a column of that row.
As you can see above I do the following to run this trigger:
ON ROW-DISPLAY PERSISTENT RUN prodCol.

Here is the problem.
I have a list of all collumn-handles but i am not able to to a check within the row-display on buffer-value or screen-value.

/*********************** PROCEDURE prodCol**********************/
DEFINE VARIABLE v_i AS INT NO-UNDO.
DEFINE VARIABLE col-handle AS HANDLE NO-UNDO.

ASSIGN v_i = 1.

DO WHILE v_i <= 8:

/*here is the problem. i can not use buffer-field, buffer-value or screen-value in this row-display trigger*/
ASSIGN fld-handle = col-handle:BUFFER-FIELD.
MESSAGE fld-handle:SCREEN-VALUE.
MESSAGE fld-handle:BUFFER-VALUE.

col-handle:BGCOLOR = 12.
ASSIGN v_i = v_i + 1.
END. /*DO WHILE v_i <= 8*/
END PROCEDURE.

The messages I got when i try to run the above or a part of it
  • 5906 : Buffer-field cannot be queried within a row-display trigger for fill in total.
  • 3135: Invalid widget-handle. Not initialised or point to a deleted widget
  • 3140: Cannot acces the Buffer-value attribute because the widget does not exist.
Can anybody help please?

Thanks a lot!

Kind regards,

Elise
 

Beeb

Member
Ok i found the solution.
instead of only make a larray of the column handles, i made also a list of the buffer field handles.

in proc prodCol i now can read the buffer-value and it becomes something like this:

ASSIGN v_i = 1.

ASSIGN fld-handle = v_buflist[8].
MESSAGE STRING(ROUND(fld-handle:BUFFER-VALUE,2)).
IF ROUND(fld-handle:BUFFER-VALUE,2)<> 8
THEN DO WHILE v_i <= 8:
ASSIGN v_col-handle = v_collist[v_i].
v_col-handle:BGCOLOR = 12.
ASSIGN v_i = v_i + 1.
END. /*DO WHILE v_i <= 8*/

greetz,

Elise
 

walkeryan

Member
Thanks I've been wondering how to do this myself, usually I just do a freeform query and run it in the Display fields, check the value there but doing it in an external Proc is a good idea.
 
Top