Welcome to the Tweaking4All community forums!
When participating, please keep the Forum Rules in mind!
Topics for particular software or systems: Start your topic link with the name of the application or system.
For example “MacOS X – Your question“, or “MS Word – Your Tip or Trick“.
Please note that switching to another language when reading a post will not bring you to the same post, in Dutch, as there is no translation for that post!
[Solved] How to replace the field type and value in dbgrid?
(@adamlevine)
New Member
Joined: 6 years ago
Posts: 1
Topic starter
March 30, 2018 6:12 PM
How to replace the field type and value in dbgrid?
My SQL query:
Code: XML [Select] DBForm.DBquery.SQL.text:='select callstart, callend, origin, destination, direction from callrecord;
termtype are integer values 0...3, instead I would like to show in dbgrid column fields: None, Incoming, Outgoing or Internal, accordingly. These text values are not stored in any DB table to be joined with; it is also not allowed to add smth to this DB (in my case). Is there a way how to do this "on fly", when the dbgrid obtains the values from the DB?
(@hans)
Famed Member Admin
Joined: 11 years ago
Posts: 2762
March 30, 2018 11:43 PM
I do not have my gear near me at the moment, but as far as I recall, you can define in the TSQLQuery (for example) the data return values in one fo the events. I think it's under "OnCalcFields". It may also have been "OnDrawColumnCell" of TDBGrid.
In Delphi, the TDBGrid has a OnGetText event - which I used to do exactly what you're doing.
A quick look at Lazarus I could not find this event (doing a quick search).
When looking in the Lazarus forum I found this post that might help: link. I assume you already looked at this link as well ...
Hope this is helpful.