PxPlus User Forum

Twitter Twitter Twitter

Author Topic: Ability to search on grid column names with GRID FIND  (Read 2492 times)

Sebastiaan Fisscher

  • Silver Member
  • ***
  • Posts: 23
    • View Profile
    • Astecom Business Software
Ability to search on grid column names with GRID FIND
« on: August 08, 2018, 08:07:59 AM »
It is possible to use a Grid Find command to get data from a grid; GRID FIND ctl_id,col,row,var$[,ERR=stmtref]
However, the fact you can't use the actual name of the column (grid.ctl'column$). GRID FIND would be more flexible if you would be able to use it like this:
GRID FIND ctl_id,(col or col$),row,var$[,ERR=stmtref]

This way, when a grid column needs to be added in between, the code will always keep working like intended. The other upside is that the code gets more readable, the name of a gridcolumn is far more understandable than a number.

It would be very helpful if you could add the ability to search on grid column names with GRID FIND.

Mike King

  • Diamond Member
  • *****
  • Posts: 3810
  • Mike King
    • View Profile
    • BBSysco Consulting
Re: Ability to search on grid column names with GRID FIND
« Reply #1 on: August 08, 2018, 09:23:21 AM »
Currently you can do the following:

Code: [Select]
  ctl_id'Column$="ColumnName"
  GRID FIND ctl_id, ctl_id'colno, row, var$

Does this not give you what you need?
Mike King
President - BBSysco Consulting
eMail: mike.king@bbsysco.com

Mike King

  • Diamond Member
  • *****
  • Posts: 3810
  • Mike King
    • View Profile
    • BBSysco Consulting
Re: Ability to search on grid column names with GRID FIND
« Reply #2 on: August 08, 2018, 11:11:56 AM »
Just curious, on re-reading your post; were you looking for a way to SEARCH the grid for text or just a way to read a specific column based on column name? Your example of using GRID FIND only returns the contents of the grid or a specific column/row, it does not search the grid for a value.

To search a GRID you need to set the property 'FindItemText$ to the value desired and the system will return the row/column in which the value is found.  There, if you want column names, you can set 'Column$ to the name of the column you want searched then set 'FindColno to the value in 'Colno and finally set 'FindItemText$ to the value to search for.  If found 'Row will have the row number, 'Colno will have the column number and 'Column$ will have the column name.

You can set specific find options with the 'FindOptions$ property such as Case insensitive, wrap around, ignore accents, search backwards, etc..
« Last Edit: August 08, 2018, 01:06:55 PM by Mike King »
Mike King
President - BBSysco Consulting
eMail: mike.king@bbsysco.com

Sebastiaan Fisscher

  • Silver Member
  • ***
  • Posts: 23
    • View Profile
    • Astecom Business Software
Re: Ability to search on grid column names with GRID FIND
« Reply #3 on: August 09, 2018, 05:15:13 AM »
My example was meant to return the content of a grid cell.
The code example does do the trick, I'll send this to my colleague so he can try this in his program.

Mike King

  • Diamond Member
  • *****
  • Posts: 3810
  • Mike King
    • View Profile
    • BBSysco Consulting
Re: Ability to search on grid column names with GRID FIND
« Reply #4 on: August 09, 2018, 08:54:07 AM »
If all you wanted was to get the contents of a grid cell then just set 'Column$ to the column name, set 'Row to the row number and read 'Value$.  You don't need to use the GRID FIND at all.  If you want to change the cell, just assign the new value to the 'Value$ property after setting row/column.

The property 'Column$ can be set to either the column number as a numeric string or the column name.  Internally it does the same as 'Colno.

BTW: Setting the two properties and just reading the value will be faster than the GRID FIND if using column names.
Mike King
President - BBSysco Consulting
eMail: mike.king@bbsysco.com

Kevin

  • New Member
  • *
  • Posts: 2
    • View Profile
Re: Ability to search on grid column names with GRID FIND
« Reply #5 on: August 10, 2018, 01:47:09 AM »
If I want to get the contents of a column, it would be nice if we could use the column name instead of number.
Like this:

Code: [Select]
GRID FIND ctl_id, columnName$, row, var$

Mike King

  • Diamond Member
  • *****
  • Posts: 3810
  • Mike King
    • View Profile
    • BBSysco Consulting
Re: Ability to search on grid column names with GRID FIND
« Reply #6 on: August 10, 2018, 09:42:21 AM »
We will take this under consideration, however please see reply number 2 in this topic as to how you can do this currently.
https://forum1.pvxplus.com/index.php?topic=125.msg292#msg292
Mike King
President - BBSysco Consulting
eMail: mike.king@bbsysco.com