Join The Works program to have access to the most current content, and to be able to ask questions and get answers from Revelation staff and the Revelation community

At 29 AUG 2023 10:55:51AM Hank Huizinga wrote:

I am attempting to use the new edittable CellChanged quick event to do validation in a commuter module.

In the past, we would add validation to the edittable colum using a custom validation procedure [procname ] and if the data was invalid the validation procedure would set the STATUS(). The user would not be allowed to leave the edit table cell until the data was corrected.

Can I replicate this in the CellChanged event? ie) Display a validation error and stop the user from leaving the cell until the data is corrected. I prefer to not clear the cell data.

I tried using Call Set_EventStatus(SETSTAT_ERR$, "EV102" ) with no success.

Any pointers are appreciated.


At 29 AUG 2023 02:55PM Hank Huizinga wrote:

This is an segment of the commuter module I am trying to write.


CellChanged:



Col 	= Param1

Row	= Param2

NewData	= Param3



BEGIN CASE

	CASE CtrlEntID = UsersTABLE	

		If Col = colRole$ Then

			GOSUB validateData

			IF NOT(valid) THEN

				** invalid data

				** stop event chain and make sure that the CellChanged event will fire again

				Call Msg(Window, "Invalid")

				Call Set_EventStatus(1, SETSTAT_ERR$)

				retval = False$			;* stop event chain	 

			End



			** do stuff



		End

End CASE


At 29 AUG 2023 04:59PM Carl Pates wrote:

Hi Hank,

In virtually all cases OI events are fired asynchronously, so by the time you get to handle the event the actual process that triggered it has finished executing - i.e. by the time you see that CELLCHANGED event the editor has been hidden and the cell contents have already been changed - you can't get "in front" of it and run your code before the control carries on processing.

The way to handle this is to validate the data as above, then, if it's incorrect move the focus back to the offending cell and switch it into EditMode etc. The trick is to block any events while you do this so you don't create a validation loop (This is the way system validation works:

e.g:

if not( valid ) then



   // Display a message

   call msg( @window, "Invalid" )



   call set_Property_Only( "SYSTEM", "BLOCK_EVENTS", TRUE$ )

   call set_Property_Only( "SYSTEM", "FOCUS", ctrlEntID )

      

   // BEGINEDIT method:

   //

   //  call exec_Method( ctrlEntID, "BEGINEDIT", colNo, rowNo, cellText, selectAll, setFocus )

   //

   // Puts a cell into editing mode, respecting it's EditMode property.

      

   call exec_Method( ctrlEntID, "BEGINEDIT", colNum, rowNum, newData, TRUE$, TRUE$ )

      

   call set_Property_Only( "SYSTEM", "BLOCK_EVENTS", FALSE$ )



end

EditTable validation in OI has always been a little messy because it has to be trapped in two places and has to check two different properties:

1) POSCHANGED - check the PREVCELLPOS

2) LOSTFOCUS - check the CARETPOS

With CELLCHANGED you are able to handle in it one location and have an accurate column and row index to check because they are passed to you.

Regards

Carl Pates


At 30 AUG 2023 08:35AM Hank Huizinga wrote:

Thank you, worked perfectly.


At 30 AUG 2023 08:45AM bob carten wrote:

In the past, we would add validation to the edittable colum using a custom validation procedure [procname ]

FWIW, In OI10 forms have a CommuterModule property. The form designer offers an '@COMMUTER' token, similar to '@SELF', or '@WINDOW'.

So, in the ICONV and OCONV for a control or editTable cell you can use something like

[@COMMUTER,MYCONTROL]

to route the validation to your commuter module

View this thread on the Works forum...

  • third_party_content/community/commentary/forums_works/3f3abbe88360d7478aab716f6ae44156.txt
  • Last modified: 2024/12/10 16:16
  • by 127.0.0.1