How can i disable one row in a browse

Posted by Admin on 11-Mar-2009 04:30

I write a program for online ordering articles at some suppliers. Therfore i have a browse with the artikels in the order. In the browse there is a checkbox for confirming the orderline in the order.

Now i wrote a testprocedure for the articles. If the article is not recognized by the suppliers I want the row disabled (The row must be visible but disabled). Those line shall be annulated in the ERP system.

Thanks

Kurt

All Replies

Posted by AdrianJones on 16-Apr-2009 05:26

you could add a value-changed trigger to test the condition and set field(s) read-only attribute accordingly.

Posted by jaison.antoniazzi on 22-Apr-2009 14:00

Hi, using Adrian's post, here is a small sample developed with appbuilder.

  1. Create a new window.
  2. Add a browser for customer (sports2000) and add some columns (custnum, name and address), enable name and address columns.
  3. Write trigger code on value-changed.
  4. Write a New Function to enable or disable the columns.

Look the file attached if you want.

On value changed trigger, step #3:

ON VALUE-CHANGED OF BROWSE-2 IN FRAME DEFAULT-FRAME /* Browse 1 */
DO:
    IF  AVAIL customer THEN DO:
        IF  customer.custnum = 5 THEN DO:
            IF disableRow( browse-2:HANDLE, FALSE ) THEN
                .
        END.
        ELSE
            IF disableRow( browse-2:HANDLE, TRUE ) THEN
                .
    END. 
END.

New function Code, step #4:

FUNCTION disableRow RETURNS LOGICAL
  ( INPUT browserHandle AS HANDLE,
    INPUT disableCol AS LOG ) :
/*------------------------------------------------------------------------------
  Purpose:  disable/enable rows in a browse
    Notes: 
------------------------------------------------------------------------------*/

    DEFINE VARIABLE icol AS INTEGER     NO-UNDO.
    DEFINE VARIABLE hcol AS HANDLE      NO-UNDO.

    IF  NOT VALID-HANDLE(browserHandle) THEN
        RETURN FALSE.

    ASSIGN
        hcol = browserHandle:FIRST-COLUMN
        hcol = hcol:NEXT-COLUMN. /*first column is disable, so get the next column*/
   
    DO WHILE VALID-HANDLE(hcol):

        hcol:READ-ONLY = NOT disableCol.

        hcol = hcol:NEXT-COLUMN.
    END.


END FUNCTION.

This thread is closed