Enable column in a dynamic browse

Posted by James Palmer on 19-Mar-2015 05:49

Progress 11.2.1.

I'v got a library that you pass a temp table and a browse widget handle and it creates the columns and query dynamically. I can share how it works, but I don't believe it's necessary for the purposes of this question. 

What I want to do is to enable one of the columns in this browse (I know what the columns are called because of the tt definition). I am having a complete mental block as to how to go about it though! Any ideas?

Thanks

All Replies

Posted by James Palmer on 19-Mar-2015 06:37

So on the value-changed trigger I can loop through the columns in the browse looking for the one that matches the one I want to enable. So now I have a handle to the column. But enabled is not a valid property. And I can't find the doc for the browse column handle.

Posted by Brian K. Maher on 19-Mar-2015 06:44
James,
 
I think the attribute you want is read-only, not enabled (i.e. handleToColumn:read-only = false to enable it).
 
Brian
 
 
Posted by James Palmer on 19-Mar-2015 06:56

Thanks Brian. I've tried that one but it didn't seem to be working. I'll give it another go though and report back.

Posted by James Palmer on 19-Mar-2015 07:00

No that's not working. Very odd. 

ON VALUE-CHANGED OF bro-MonthToDate IN FRAME FRA-BGTicker
  DO:
    DEFINE VARIABLE lv-i AS INTEGER NO-UNDO.
    DO lv-i = 1 TO BROWSE bro-MonthToDate:NUM-COLUMNS:
      IF bro-MonthToDate:GET-BROWSE-COLUMN(lv-i):NAME EQ "M2DSales" THEN
      DO:
        bro-MonthToDate:GET-BROWSE-COLUMN(lv-i):READ-ONLY = FALSE.
        MESSAGE "**JP**" bro-MonthToDate:GET-BROWSE-COLUMN(lv-i):READ-ONLY
          VIEW-AS ALERT-BOX.
      END.
    END. 
  END.


Posted by Brian K. Maher on 19-Mar-2015 07:01
 
If it still doesn't work please post your code.
 
 
Posted by James Palmer on 19-Mar-2015 07:03
PROCEDURE CreateBrowse:
  /*------------------------------------------------------------------------------
   Purpose:
   Notes:
  ------------------------------------------------------------------------------*/
  DEFINE INPUT  PARAMETER ip-TableHandle  AS HANDLE NO-UNDO.
  DEFINE INPUT  PARAMETER ip-BrowseHandle AS HANDLE NO-UNDO.

  DEFINE VARIABLE lv-ColList AS CHARACTER NO-UNDO.

  IF VALID-HANDLE(lv-DefaultBufferHandle) THEN
    lv-DefaultBufferHandle:EMPTY-TEMP-TABLE().
  EMPTY TEMP-TABLE tt-Columns.
  lv-RecordCount = 0.

  CREATE BUFFER lv-Buffer FOR TABLE ip-TableHandle:DEFAULT-BUFFER-HANDLE.

  FieldLoop:
  DO lv-i = 1 TO lv-Buffer:NUM-FIELDS:
    lv-Field = lv-Buffer:BUFFER-FIELD(lv-i).
    /*  IF GetAttribute(lv-Field:HELP,"Display") EQ "No" THEN*/
    /*    NEXT FieldLoop.                                    */

    CREATE tt-Columns.
    ASSIGN
      tt-Columns.ColumnName   = lv-Field:NAME
      tt-Columns.ColumnLabel  = lv-Field:COLUMN-LABEL
      tt-Columns.ColumnFormat = lv-Field:FORMAT
      tt-Columns.OrigDataType = lv-Field:DATA-TYPE
      tt-Columns.DataType     = IF GetAttribute(lv-Field:HELP,"DataType") NE "" THEN GetAttribute(lv-Field:HELP,"DataType") ELSE lv-Field:DATA-TYPE
      tt-Columns.ColumnOrder  = lv-i
      tt-Columns.DisplayCol   = GetAttribute(lv-Field:HELP,"Display") NE "No".
  END.

  IF VALID-HANDLE(lv-TTHandle) THEN
  DO:
    DELETE OBJECT(lv-TTHandle).
    lv-TTHandle = ?.
  END.

  CREATE TEMP-TABLE lv-TTHandle.

  FOR EACH tt-Columns BY tt-Columns.ColumnOrder:
    lv-TTHandle:ADD-NEW-FIELD(tt-Columns.ColumnName,tt-Columns.DataType,?,tt-Columns.ColumnFormat,?,tt-Columns.ColumnLabel,tt-Columns.ColumnLabel).
  END.

  lv-TTHandle:TEMP-TABLE-PREPARE("tt-" + ip-BrowseHandle:NAME).
  lv-DefaultBufferHandle = lv-TTHandle:DEFAULT-BUFFER-HANDLE.

  CREATE QUERY lv-Query.
  lv-Query:SET-BUFFERS(lv-Buffer).

  lv-QueryString = "FOR EACH " + ip-TableHandle:NAME.

  lv-Query:QUERY-PREPARE(lv-QueryString).

  lv-Query:QUERY-OPEN.

  DO WHILE lv-Query:GET-NEXT():
    lv-RecordCount = lv-RecordCount + 1.
    lv-DefaultBufferHandle:BUFFER-CREATE.

    FOR EACH tt-Columns:
      IF tt-Columns.OrigDataType NE tt-Columns.DataType THEN
      DO:
        CASE tt-Columns.DataType:
          WHEN "CHARACTER" THEN
            lv-DefaultBufferHandle:BUFFER-FIELD(tt-Columns.ColumnName):BUFFER-VALUE = STRING(lv-Buffer:BUFFER-FIELD(tt-Columns.ColumnName):BUFFER-VALUE).
          WHEN "DECIMAL" THEN
            lv-DefaultBufferHandle:BUFFER-FIELD(tt-Columns.ColumnName):BUFFER-VALUE = DEC(lv-Buffer:BUFFER-FIELD(tt-Columns.ColumnName):BUFFER-VALUE).
          WHEN "INTEGER" THEN
            lv-DefaultBufferHandle:BUFFER-FIELD(tt-Columns.ColumnName):BUFFER-VALUE = INT(lv-Buffer:BUFFER-FIELD(tt-Columns.ColumnName):BUFFER-VALUE).
        END CASE.
      END.
      ELSE
        lv-DefaultBufferHandle:BUFFER-FIELD(tt-Columns.ColumnName):BUFFER-VALUE = lv-Buffer:BUFFER-FIELD(tt-Columns.ColumnName):BUFFER-VALUE.
    END.

  END.

  lv-Query:QUERY-CLOSE.
  DELETE OBJECT lv-Query.

  CREATE QUERY lv-Query.
  lv-Query:SET-BUFFERS(lv-DefaultBufferHandle).

  IF lv-TheSortColumn NE "" THEN 
    lv-QueryString = "FOR EACH " + lv-TTHandle:NAME + " BY " + lv-TTHandle:NAME + "." + lv-TheSortColumn + (IF lv-UpDown EQ "Down" THEN " DESC" ELSE "").
  ELSE 
    lv-QueryString = "FOR EACH " + lv-TTHandle:NAME.
  
  lv-Query:QUERY-PREPARE(lv-QueryString).


  ASSIGN
    ip-BrowseHandle:QUERY = lv-Query.

  FOR EACH tt-Columns
    WHERE tt-Columns.DisplayCol:
    tt-Columns.ColumnHandle = ip-BrowseHandle:ADD-LIKE-COLUMN(lv-TTHandle:NAME + "." + tt-Columns.ColumnName).
  END.

  lv-Query:QUERY-OPEN.

  IF lv-Query:NUM-RESULTS GT 0 THEN
    APPLY "VALUE-CHANGED" TO ip-BrowseHandle.

  ASSIGN
    ip-BrowseHandle:SENSITIVE              = TRUE
    ip-BrowseHandle:COLUMN-MOVABLE         = FALSE
    ip-BrowseHandle:ALLOW-COLUMN-SEARCHING = TRUE
    ip-BrowseHandle:COLUMN-RESIZABLE       = TRUE.

  ON "START-SEARCH" OF ip-BrowseHandle PERSISTENT RUN "StartSearch" IN THIS-PROCEDURE (INPUT ip-BrowseHandle).

  RUN GenerateBrowsePopupMenu IN THIS-PROCEDURE (INPUT ip-BrowseHandle).
  
  IF lv-TheSortColumn NE "" THEN 
    RUN RedoSort IN THIS-PROCEDURE (INPUT ip-BrowseHandle).

END PROCEDURE.

Posted by Brian K. Maher on 19-Mar-2015 07:04
 
Does the message statement return true or false for the value of the read-only attribute?
 
 
Posted by James Palmer on 19-Mar-2015 07:04

Returns false.

Posted by Matt Gilarde on 19-Mar-2015 07:06

I think you have to set READ-ONLY = FALSE on both the column and the browse itself.

Posted by James Palmer on 19-Mar-2015 07:13

Matt you are a star. That sorted it!

Posted by Brian K. Maher on 19-Mar-2015 07:18
 
Glad you got it sorted out.
 
For everyone else, if the browse itself is read-only then setting read-only on columns will return false.
 
 
Posted by James Palmer on 19-Mar-2015 09:58

Thanks for everyone's help.

Unfortunately my brain block is still happening and I can't figure out how to go about capturing the user entered values in the browse so I can ultimately save them back to the database.

Posted by Brian K. Maher on 19-Mar-2015 10:06
handleToColumn:SCREEN-VALUE
 
[collapse]
From: James Palmer [mailto:bounce-jdpjamesp@community.progress.com]
Sent: Thursday, March 19, 2015 10:59 AM
To: TU.OE.Development@community.progress.com
Subject: RE: [Technical Users - OE Development] Enable column in a dynamic browse
 
Reply by James Palmer

Thanks for everyone's help.

Unfortunately my brain block is still happening and I can't figure out how to go about capturing the user entered values in the browse so I can ultimately save them back to the database.

Stop receiving emails on this subject.

Flag this post as spam/abuse.

[/collapse]
Posted by James Palmer on 19-Mar-2015 10:14

Thanks Brian. That's the one of course.

This thread is closed