1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Question How to use Delete-Current-Row() method?

Discussion in 'Development' started by reynold12, Oct 21, 2013.

  1. reynold12

    reynold12 New Member

    Hello All -

    I am using OpenEdge 10.2B with windows XP.
    I just want to understand about browser methods provided by OE.

    I want to delete some records from my browser(or in other words dont want to display it on screen) on the basis of some condition .. like when value of a variable = xyz.

    I understand from the help given by OE that Delete-Current-Row() and Delete-Selected-Row() methods will be suitable for my situation, but I really dont know where to write those methods in my abc.w file (like under which procedure or trigger).

    what exactly I want is:

    def var cKt as char no-undo.
    ...... on some DB query I can assign cKt with some values.......
    if cKt = "xyz" then
    browse {browser-name}:Delete-Current-Row().

    I tried to place that code under Row-Display trigger but it was giving run-time error that I cant run the method under Row-Display trigger. So I want How/Where should I Use/Place Delete-Current-Row() or Delete-Selected-Row() methods?

    Thanks.
     
  2.  
  3. Hi Reynold,
    If you would want to delete a row on the "Row Display" event would it not be better to tune the where phrase of your browser query?
    Thanks
    Joel
     
  4. reynold12

    reynold12 New Member

    hello Joel -Thanks for your reply. But the suggestion you gave is the easiest way to modify the query itself. but I can't do that that's the reason I want too understand from some expert how to use those browser methods and which is the best place/procedure to place that. Hope you understand my concern. Thanks.



     
  5. reynold12

    reynold12 New Member

    Could anyone can help me on this ... like how do I use Delete-Current-Row() and Delete-Selected-Row() methods given by progress with some small code snippet (like in which trigger or procedure I should write those methods)..??
     
  6. rzr

    rzr Member

     
  7. rzr

    rzr Member

    Add button for delete operation and write this CHOOSE trigger for the new button:

    Code (progress):
    1.  
    2. DO:
    3.     DEFINE VARIABLE iRow AS INTEGER NO-UNDO.
    4.     DO iRow = 1 TO hBrowse:NUM-SELECTED-ROWS:
    5.         hBrowse:FETCH-SELECTED-ROW(iRow).
    6.         DELETE ttOline.
    7.     END.
    8.     hBrowseELETE-SELECTED-ROWS().
    9. END.
    10.  
     
  8. reynold12

    reynold12 New Member

    The options you suggested won't fit for me but Thanks for your reply.
    First thing - I don't want to delete the record from the Database.
    My Exact Requiremet is: When I press the Search/Refresh button which actually runs the query of DB table and display the data in the browser. I can't change the pre written Query filter criteria. But, still I need to implement is to check the Data on the basis of some security setting and if it fails, don't display in the Browser. For this change I don't need any button action as well.
    I hope you understand my case.
    Could you/anyone suggest some solution for such a case.
    Thanks in advance.
     
  9. rzr

    rzr Member



    Why can't you do this? Is there any restriction?

    to "refresh" your browse display you will need to either open/close the query that populates the browse or open the query with the "modified" filter condition.
    Do you have an option to modify the "source" for your browse. If yes then you can build your browse on this new source that can contain all the data from previous source + the filter check.
     
  10. reynold12

    reynold12 New Member

    Yes, we have a restriction to change the existing Query. In other words you are saying there is no other way to get the expected result what I am expecting in my above post without modifying the query criteria?

    Can't we achieve the expected result without touching the existing query criteria by using some other Progress Methods/Statements?

    In simple words - I don't want to display some particular grid rows/records on the basis of some condition and that too after the query ran and without modifying the query itself.
     
  11. Osborne

    Osborne Active Member

    As rzr posted, changing the query is the option to use.

    I suppose you could do something like this which first loads all the records then removes from the browse all odd numbers, but not sure how practical this really is:
    Code (progress):
    1.  
    2. DEFINE VARIABLE vi AS INTEGER NO-UNDO.
    3. DEFINE VARIABLE vRowid AS ROWID NO-UNDO.
    4.  
    5. DEFINE TEMP-TABLE ttNumbers NO-UNDO
    6.        FIELD nField AS INTEGER LABEL "Number"
    7.        INDEX nfield IS UNIQUE PRIMARY nField.
    8.  
    9. DEFINE QUERY q1 FOR ttNumbers SCROLLING.
    10. DEFINE BROWSE b1 QUERY q1 DISPLAY ttNumbers.nField WITH MULTIPLE 10 DOWN.
    11.  
    12. DEFINE BUTTON button1 LABEL "Remove Odd Numbers".
    13.  
    14. DEFINE FRAME f1 b1 SKIP(1) button1 WITH SIDE-LABELS AT ROW 2 COLUMN 2.
    15.  
    16. ON CHOOSE OF button1
    17. DO:
    18.    GET FIRST q1.
    19.    DO WHILE AVAILABLE(ttNumbers):
    20.       IF ttNumbers.nField = 1 OR ttNumbers.nField = 3 OR
    21.          ttNumbers.nField = 5 OR ttNumbers.nField = 7 OR
    22.          ttNumbers.nField = 9 THEN DO:
    23.          vRowid = ROWID(ttNumbers).
    24.          REPOSITION q1 TO ROWID vRowid.
    25.          b1:SELECT-FOCUSED-ROW().
    26.       END.
    27.       GET NEXT q1.
    28.    END.
    29.    IF b1:NUM-SELECTED-ROWS > 0 THEN
    30.       b1:DELETE-SELECTED-ROWS().
    31. END.
    32.  
    33. DO vi = 1 TO 10:
    34.    CREATE ttNumbers.
    35.    ASSIGN ttNumbers.nField = vi.
    36. END.
    37.  
    38. OPEN QUERY q1 FOR EACH ttNumbers.
    39. ENABLE b1 button1 WITH FRAME f1.
    40. WAIT-FOR WINDOW-CLOSE OF CURRENT-WINDOW.
    41.  
     
  12. reynold12

    reynold12 New Member

    I can't use any button to delete the selected-rows. When I am trying to put code containing method to selcet-Focused-row under Row-Display Trigger, it giving me runtime error that I can't use those methods Select-Focused-row() and Delete-Selected_row() in Row-Display.

    So could you suggest where I can put/use those methods under some triggers where before displaying to grid I can take that action and decide to display it in grid or not?
     
  13. Osborne

    Osborne Active Member

    The best place would be to put into an internal procedure and run every time the browse query is updated:
    Code (progress):
    1.  
    2. ENABLE b1 button1 WITH FRAME f1.
    3.  
    4. OPEN QUERY q1 FOR EACH ttNumbers.
    5. RUN remove_browse_records.
    6.  
    7. PROCEDURE remove_browse_records:
    8.    DEFINE VARIABLE vRowid AS ROWID NO-UNDO.
    9.  
    10.    GET FIRST q1.
    11.    DO WHILE AVAILABLE(ttNumbers):
    12.       IF ttNumbers.nField = 1 OR ttNumbers.nField = 3 OR
    13.          ttNumbers.nField = 5 OR ttNumbers.nField = 7 OR
    14.          ttNumbers.nField = 9 THEN DO:
    15.          vRowid = ROWID(ttNumbers).
    16.          REPOSITION q1 TO ROWID vRowid.
    17.          b1:SELECT-FOCUSED-ROW().
    18.          b1:DELETE-SELECTED-ROWS().
    19.       END.
    20.       GET NEXT q1.
    21.    END.
    22. END PROCEDURE.
    23.  
     
  14. LarryD

    LarryD Member

    you might want to try a variation on this (assuming you are opening the query with the table)

    Code (progress):
    1.  
    2.  
    3. on find of mydbtable do:
    4.     if mydbtable.cKt = "xyz"
    5.     then return error.
    6. end.
    7.  
    8.  
     

Share This Page