1. Jim Means
  2. PowerBuilder
  3. Wednesday, 30 October 2019 23:20 PM UTC

Hey gang,

Without getting too far into the specifics of my modifications, my remaining PB app runs in Windows Classic Style.  I need to know if there's a PowerScript function to clear the data entered into a datawindow (not yet saved to the DB), acting exactly like the "Clear" icon in the menu bar.  If it mechanically answered "No" to the "Do you want to save changes?" question (behind the scenes), that'd be great, too.

I tried to use datawindowname.RESET(), but that just made the datawindow disappear from the window (there are 2 in DWs this window), so that was a bust.

I've read up on the CLEAR function, but that doesn't sound like the same thing as the Clear icon.

I'm in a bit of a time crunch on this.

Thanks in advance,

Jim

 

 

 

Accepted Answer
Jim Means Accepted Answer Pending Moderation
  1. Thursday, 31 October 2019 18:08 PM UTC
  2. PowerBuilder
  3. # Permalink

Hey All,

I figured it out myself.  Triggered the ue_clear() event for the window. It still asks if the user wants to save changes, but I can work around that.

Thanks,

Jim

 

 

Comment
  1. Miguel Leeuwe
  2. Friday, 1 November 2019 02:36 AM UTC
No disrespect, but you speak of icons and events (ue_clear) without us having a clue about them. ue_clear probably does what one of us has explained to you. If you don't want to be asked to save changes, then do a something like dw_1.ResetUpdate() after calling your event ue_clear.

Glad you solved it.

regards
  1. Helpful
  1. Jim Means
  2. Thursday, 7 November 2019 00:22 AM UTC
Apologies to the community, Miguel,

I inherited this app and PB with it several years back. No training, you know the drill. Never had the time to learn everything I should probably know to support it, but I've managed. I only remembered seeing that ue_clear event in most of the windows in this app only after I did a search on 'clear', then it was a forehead slap and a D'OH moment. I still don't understand PBLs and am struggling with another issue now that I'll probably post about soon. I hope I'm able to describe it better.
  1. Helpful
There are no comments made yet.
Olan Knight Accepted Answer Pending Moderation
  1. Thursday, 31 October 2019 23:05 PM UTC
  2. PowerBuilder
  3. # 1

ll_rc = dw_1.Reset()

 

Olan

Comment
There are no comments made yet.
Brad Mettee Accepted Answer Pending Moderation
  1. Thursday, 31 October 2019 16:07 PM UTC
  2. PowerBuilder
  3. # 2

If you're looking to simply discard the row without affecting the database, try the RowsDiscard(start, stop, buffer) method.

 

Comment
There are no comments made yet.
Michael Kramer Accepted Answer Pending Moderation
  1. Thursday, 31 October 2019 11:49 AM UTC
  2. PowerBuilder
  3. # 3

Restoring a row can be done in multiple ways depending on how that row was "created".

  • Row retrieved from DB
    • Restore row to the same state it now has in the database => ReselectRow(…)
    • Restore row to the same state as it had when you retrieved it but potentially no longer because it may have changed in the database => More complex/more code => for each column
      • Get original item value to set the current value
      • Restore item's status to NotModified!
      • After all columns restored => Restore row's state to NotModified!
    • Recommendation: Go with ReselectRow unless you really need to insist on potentially looking at outdated data
  • Row inserted by user/app
    • Remove the current row => DeleteBow(…)
    • Add new row at same position => InsertRow(…)
    • Restore focus to the new row => ScrollToRow(…)/SetRow(…)
  • Restoring all content of DataWindow to state it has in database => Retrieve(...)
  • Clearing DataWindow of all its content but keep one empty row for editing
    • Remove all existing data from the buffers => Reset(…)
    • Add new row for data entry => InsertRow( 0 )

This hopefully covers your base and more for later reference.

HTH /Michael

Comment
There are no comments made yet.
Miguel Leeuwe Accepted Answer Pending Moderation
  1. Thursday, 31 October 2019 01:19 AM UTC
  2. PowerBuilder
  3. # 4

Hi,

What / which / where is the ""Clear" icon in the menu bar"?

Are you showing one row (Freeform dw)?

-------------- steps -----------------------

// 1:

dw_1.Reset() // clears the whole datawindow, not a single row left on the dw.

// 2:

dw_1.InsertRow(0) // makes the dw appear without data showing the fields and labels and a dwItemStatus New!

 

// 3:

dw_1.ResetUpdate() 

// OR ...:

//3:

dw_1.Retrieve(...) // to get the data back that was showing

// OR ...:

//3:

// Do nothing else

-----------------------------

Another thing you could do to get back the data in the state that it was after having done a retrieve, is to work with the Data and primary!, original! buffer, but it all depends on which state you want the data to end up.

Comment
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Wednesday, 30 October 2019 23:34 PM UTC
  2. PowerBuilder
  3. # 5

Hi Jim;

  The Reset() command is the correct one. It doesn't clear the DWO - just it's buffers. Of course with no data, the DW Control space may seem empty. It would depend if the DWO had literal Header and/or Footer labels.

  To clear the DWO, you would code ...

      DC.DataObject = ""

  Of course, the DW Control would be unusable after that.

HTH

Regards... Chris

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.