1. Milan Shah
  2. PowerBuilder
  3. Wednesday, 19 October 2022 09:49 AM UTC

Hi, I am using userobject structure to fill datawindow data.                                                                                                                                     i want to know how can i trigger itemchanged event for validate some column data 

My Code is Here

n_salememo lnv_salememo
lnv_salememo = create n_salememo

ib_retrivests = False
For ll_row = 1 To adw_memo.RowCount( ) Step 1
    /*statementblock*/
    ll_sel4pur = adw_memo.GetItemNumber( ll_row, "paperno")
    If ll_sel4pur = 1 Then
        i = i + 1
        lnv_salememo.memno[i] = string(adw_memo.GetItemNumber( ll_row, "xtno"))
        lnv_salememo.lotid[i] = adw_memo.GetItemNumber( ll_row, "lotid")
        lnv_salememo.lotper[i] = adw_memo.GetItemString( ll_row, "lotper")
        lnv_salememo.m2spcs[i] = adw_memo.GetItemNumber( ll_row, "m2spcs")
        lnv_salememo.m2scts[i] = adw_memo.GetItemDecimal( ll_row, "m2scts")
        lnv_salememo.m2sprc[i] = adw_memo.GetItemDecimal( ll_row, "m2sprc")
        lnv_salememo.intper[i] = adw_memo.getitemdecimal( ll_row, "intper" )
        lnv_salememo.uid[i] = gstr_cominfo.usrid
        lnv_salememo.ustamp[i] = DateTime(Today(), Now())
    End If
Next
dw_detail.object.lotid.primary.Current = lnv_salememo.lotid[]
dw_detail.object.lotper.primary.Current = lnv_salememo.lotper[]
dw_detail.object.lotpcs.primary.Current = lnv_salememo.m2spcs[]
dw_detail.object.lotcts.primary.Current = lnv_salememo.m2scts[]
dw_detail.object.lotprc.primary.Current = lnv_salememo.m2sprc[]
dw_detail.object.intper.primary.Current = lnv_salememo.intper[]
dw_detail.Sort( )
dw_detail.accepttext( )
ib_retrivests = True

Destroy lnv_salememo

Accepted Answer
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Wednesday, 19 October 2022 15:45 PM UTC
  2. PowerBuilder
  3. # Permalink

Hi Milan ;

  The AcceptText() will attempt to trigger the DWO's validation. However, that is when the data is in the keyboard buffer vs the DWO's primary buffer. Your code is loading the DWO's primary buffer directly, so there is no validation when the AcceotText command is encountered. In order to make this validation happen by the DWO, you need to load its keyboard buffer instead using the SetText() command and not the DOT notation in your code example.

HTH

Regards ... Chris

Comment
  1. Milan Shah
  2. Wednesday, 19 October 2022 18:10 PM UTC
hi, then what i have to do. If I play a loop for each row then it will take too much time. suggest any other method
  1. Helpful
  1. Milan Shah
  2. Wednesday, 19 October 2022 18:20 PM UTC
If I want to use settext () then how will my code look like can you give some example for that
  1. Helpful
  1. Chris Pollach @Appeon
  2. Wednesday, 19 October 2022 18:53 PM UTC
Hi Milan;

Then you would use a SetColumn() + SetText() command in a loop for each DWO column. Then after that the AcceptText() would perform the last column validation from the KeyBoard buffer into the Primary buffer. Note that this validation also takes place on each Row/Column focus change. So you would need logic in the ItemError event to handle any data validation issues.

The other approach would be to loop through the DWO's primary buffer instead of the SetText route and check each column's update flag (via the GetItemStatus command). If changed, then validate the data under PowerScript control in the primary buffer.

Regards ... Chris
  1. Helpful 1
There are no comments made yet.
Milan Shah Accepted Answer Pending Moderation
  1. Thursday, 20 October 2022 13:59 PM UTC
  2. PowerBuilder
  3. # 1

Thank you Every One for your suggestion.

Comment
There are no comments made yet.
Olan Knight Accepted Answer Pending Moderation
  1. Wednesday, 19 October 2022 20:05 PM UTC
  2. PowerBuilder
  3. # 2

Milan -

   Try this:

dw_detail.object.lotid.primary.Current  = lnv_salememo.lotid[]
dw_detail.object.lotper.primary.Current = lnv_salememo.lotper[]
dw_detail.object.lotpcs.primary.Current = lnv_salememo.m2spcs[]
dw_detail.object.lotcts.primary.Current = lnv_salememo.m2scts[]
dw_detail.object.lotprc.primary.Current = lnv_salememo.m2sprc[]
dw_detail.object.intper.primary.Current = lnv_salememo.intper[]

ll_rc = 0
ll_rowcount = dw_detail.RowCount ()

FOR ll_row = 1 TO ll_rowcount
   ll_rc_new = dw_detail.SetItemStatus (0, DataModified!, Primary!)
   ll_rc     = ll_rc + ll_rc_new
NEXT

If (ll_rc = ll_rowcount) THEN

   // No errors occurred
   dw_detail.Sort( )
   dw_detail.accepttext( )
   ib_retrivests = True

ELSE
   // .... try something else or declare an error and exit
END IF


Comment
There are no comments made yet.
René Ullrich Accepted Answer Pending Moderation
  1. Wednesday, 19 October 2022 10:26 AM UTC
  2. PowerBuilder
  3. # 3

Hi Milan,

Dot notation (and also SetItem) changes the data directly in the buffer. Itemchanged event will only be fired if data will be transfered from "edit control" to buffer. So the right way would be to change the text in the "edit control" using SetText and after that transfer the value to buffer using Accepttext. You need to do it for each column. This would also validate the data using validation expressions.

If you just need to run some code in itemchanged event you can do it this way (__get_attribute is undocumented feature!):

Event itemchanged (ll_row, this.object.__get_attribute (ls_columnname, TRUE), ls_value)

But: This will not use the validation expressions and you can't reject the value in the itemchanged event because it is already in the buffer!

HTH,

René

 

Comment
  1. Milan Shah
  2. Wednesday, 19 October 2022 11:27 AM UTC
So i hv to play with loop for each row and column right?
  1. Helpful
  1. René Ullrich
  2. Wednesday, 19 October 2022 11:45 AM UTC
I don't know another way.
  1. Helpful 2
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.