Ability to search on grid column names with GRID FIND

Started by Sebastiaan Fisscher, August 08, 2018, 08:07:59 AM

Previous topic - Next topic

Sebastiaan Fisscher

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

Currently you can do the following:

  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 - http://www.bbsysco.com
eMail: mike.king@bbsysco.com

Mike King

#2
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..
Mike King
President - BBSysco Consulting - http://www.bbsysco.com
eMail: mike.king@bbsysco.com

Sebastiaan Fisscher

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

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 - http://www.bbsysco.com
eMail: mike.king@bbsysco.com

Kevin

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:

GRID FIND ctl_id, columnName$, row, var$
Astecom Business Software 
Smart solutions. Real results. 
👤 Kevin – Owner & Developer 
🔧 PxPlus | ☁️ Webapps | 🔗 Integrations 
🌐 www.astecom.nl

Mike King

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 - http://www.bbsysco.com
eMail: mike.king@bbsysco.com