PxPlus User Forum

Twitter Twitter Twitter

Author Topic: Grid cell validation logic and CellTag  (Read 2142 times)

Jeff Wilder

  • Silver Member
  • ***
  • Posts: 42
    • View Profile
Grid cell validation logic and CellTag
« on: September 30, 2019, 12:45:12 PM »
Hello,
I am using PxPlus 2019. I have a Nomads panel containing a grid with cell generic validation and formatting logic defined in Nomads (such as a date validate/format).  My desire is to use the CellTag value to make logic decisions inside the validation and formatting logic. However, Nomads appears to always send the tag field from the grid control and not that of the individual cell that fired the validation/format event. I don't want to use the grid tag, because not all cells contain the same CellTag data.

Is there something I can do to cause Nomads to send the cell tag and not the grid tag? If not, is there another way to pass extra cell related data to the validate/format grid cell logic at runtime?

Best Regards,
Jeff

Mike King

  • Diamond Member
  • *****
  • Posts: 3810
  • Mike King
    • View Profile
    • BBSysco Consulting
Re: Grid cell validation logic and CellTag
« Reply #1 on: September 30, 2019, 01:23:41 PM »
Have you tried using the 'CellTag$ property?
Mike King
President - BBSysco Consulting
eMail: mike.king@bbsysco.com

Jeff Wilder

  • Silver Member
  • ***
  • Posts: 42
    • View Profile
Re: Grid cell validation logic and CellTag
« Reply #2 on: September 30, 2019, 02:47:57 PM »
Yes. I have set the CellTag$ property of the individual cell. When I trace back from my validation routine, it appears to be called from the following line in *winproc:
Code: [Select]
2280 IF _OBJ_TYPE$="G" \
  THEN CALL _INP_TBL$[_ID,_WDW_INDX],ERR=2320,_X$,ID.COLUMN,ID.ROW,_ERR$,EVS(ID$+".tag$"),EVS(ID$+_SFX$),_EOM$ \
  ELSE CALL _INP_TBL$[_ID,_WDW_INDX],ERR=2320,_X$,_ERR$,EVS(ID$+".tag$"),_X_OLD$,_EOM$
The tag value sent into my call routine is from the grid control (e.g. GRID_1.TAG$) and not the 'CellTag$ property of the cell I am validating.  A similar thing occurs in the format routine.  Am I missing something or am I using this improperly?

I thought about using the grid row and column values to read the 'CellTag$ property, but I am trying to use a generic validator and formatter. It wouldn't necessarily know the grid's ctl value.

Thanks,
Jeff

Mike King

  • Diamond Member
  • *****
  • Posts: 3810
  • Mike King
    • View Profile
    • BBSysco Consulting
Re: Grid cell validation logic and CellTag
« Reply #3 on: September 30, 2019, 02:55:08 PM »
I believe CTL will have the handle to the Grid control so you should be able to use that.
Mike King
President - BBSysco Consulting
eMail: mike.king@bbsysco.com

Jeff Wilder

  • Silver Member
  • ***
  • Posts: 42
    • View Profile
Re: Grid cell validation logic and CellTag
« Reply #4 on: September 30, 2019, 03:08:19 PM »
Yes. CTL does have the grid's ctl value. That would work except when the format routine is called after returning from a query button press in a 'Lookup' CellType.  In that case, CTL is a value which does not appear to represent an object (in my case 10016).

Mike King

  • Diamond Member
  • *****
  • Posts: 3810
  • Mike King
    • View Profile
    • BBSysco Consulting
Re: Grid cell validation logic and CellTag
« Reply #5 on: September 30, 2019, 09:37:52 PM »
Okay, then why not set the Tag$ to an expression of STR(Id) then you can find the grid Id from the tag value.
Mike King
President - BBSysco Consulting
eMail: mike.king@bbsysco.com

Jeff Wilder

  • Silver Member
  • ***
  • Posts: 42
    • View Profile
Re: Grid cell validation logic and CellTag
« Reply #6 on: October 01, 2019, 11:05:47 AM »
Thank you Mike. That will take care of my needs.

Mike King

  • Diamond Member
  • *****
  • Posts: 3810
  • Mike King
    • View Profile
    • BBSysco Consulting
Re: Grid cell validation logic and CellTag
« Reply #7 on: October 01, 2019, 11:18:04 AM »
There actually is another 'sneaky' way to access the ID by in your called validation program issuing a simple "ENTER" which converts the CALL to a PERFORM. 

This will allow you access ALL variables from the main WINPROC level however you would need to make sure you didn't change anything accidentally.

Personally I don't ever recommend this approach as it can be difficult to debug and is not very intuitive however this capability was added to PxPlus/ProvideX long ago to provide compatibility with other BB dialects.
Mike King
President - BBSysco Consulting
eMail: mike.king@bbsysco.com

Jeff Wilder

  • Silver Member
  • ***
  • Posts: 42
    • View Profile
Re: Grid cell validation logic and CellTag
« Reply #8 on: October 01, 2019, 11:22:59 AM »
Interesting. I was not aware of that feature. If the ID value in the grid tag doesn't work out, I will look into it, but it does sound like a potentially risky method (especially if another programmer comes by later without realizing what is happening.)

Thanks again. Great ideas!