Row-Display - Dynamic Browse

balta

Member
Hello,

Anyone have an example of a row-display with a dynamic browse?

I have searched in Web but without success.

Thanks in Advance
Baltazar
 
The following example will create a dynamic window, frame, browse and temp-table. The row-display trigger is used to set the background color of the rows:
Code:
var handle hwwin, hwfrm, hwbr, ht, hb, hq, hp.
var handle [2] hwcol.

function createRow logical private (
   i_hb as handle, 
   i_ii as int,
   i_cc as char
):

   i_hb:buffer-create().
   assign
      i_hb::id = i_ii
      i_hb::description = i_cc
      .     

end function.


create temp-table ht.
ht:add-new-field( 'id', 'int64' ).
ht:add-new-field( 'description', 'character' ).
ht:temp-table-prepare( 'dynamic' ).
hb = ht:default-buffer-handle.

createRow( hb, 1, 'one' ).
createRow( hb, 2, 'two' ).
createRow( hb, 3, 'three' ).
createRow( hb, 4, 'four' ).


create window hwwin assign 
   width = 100
   height = 20
   status-area = false
   message-area = false
   visible = true
   .
   
create frame hwfrm assign
   parent = hwwin
   width = hwwin:width
   height = hwwin:height
   visible = true
   .

create query hq.
hq:add-buffer( hb ).
hq:query-prepare( substitute( 'for each &1', hb:name ) ).

create browse hwbr assign
   frame = hwfrm
   query = hq
   width = hwfrm:width - 1
   height = hwfrm:height - 1
   
   visible = true
   sensitive = true
   .
   
hwcol[1] = hwbr:add-like-column( hb:buffer-field( 'id' ) ).
hwcol[2] = hwbr:add-like-column( hb:buffer-field( 'description' ) ).

hp = this-procedure.
on row-display of hwbr persistent run RowTrigger in hp ( hwbr:query, hwcol ).

hq:query-open().

wait-for close of hwwin.

procedure RowTrigger:
   define input parameter i_hq      as handle no-undo.
   define input parameter i_hwcol   as handle no-undo extent.
   
   var handle hb.
   var int ix.
   
   if valid-handle( i_hq ) then do:
      
      hb = i_hq:get-buffer-handle(1).
      if valid-handle( hb ) then do:
      
         do ix = 1 to extent( i_hwcol ):
            i_hwcol [ix]:bgcolor = 13 + ( hb::id modulo 2 ).
         end.
         
      end.
         
   end.
   
end procedure.
 
Thanks a Lot!!! With the code you sent, I have managed to do what I want! :)

This code is OpenEdge 12.8? (I am in OpenEdge 12.2)
 
I'm not sure what you mean by this. What is faster than what? Can you provide an example of what you mean?
Also multiple variables of the same type on one line and more concise extents, my two lines above would need to be the following pre-var:

Code:
define variable hwwin as handle no-undo.
define variable hwfrm as handle no-undo.
define variable hwbr as handle no-undo.
define variable ht as handle no-undo.
define variable hb as handle no-undo.
define variable hq as handle no-undo.
define variable hp as handle no-undo.
define variable hwcol as handle no-undo extent 2.

I prefer the two-liner:

Code:
var handle hwwin, hwfrm, hwbr, ht, hb, hq, hp.
var handle [2] hwcol.

Oh, if only I could drop support for 12.2 :)
 
Also multiple variables of the same type on one line and more concise extents, my two lines above would need to be the following pre-var:

Code:
define variable hwwin as handle no-undo.
define variable hwfrm as handle no-undo.
define variable hwbr as handle no-undo.
define variable ht as handle no-undo.
define variable hb as handle no-undo.
define variable hq as handle no-undo.
define variable hp as handle no-undo.
define variable hwcol as handle no-undo extent 2.

I prefer the two-liner:

Code:
var handle hwwin, hwfrm, hwbr, ht, hb, hq, hp.
var handle [2] hwcol.

Oh, if only I could drop support for 12.2 :)

I understand that the rcode for VAR is the same as for DEFINE VARIABLE.

So you might be able to run rcode compiled in 12.5 or whenever with a 12.2 runtime. Would not recommend or ever suggest that in anything but a toy environment, but might be a fun exercise.
 
Back
Top