delphidevexpresstcxgrid

How to use subfields from ADT fields in cxGrid?


I',m trying to use some ADT subfields added in a TFDQuery in a TcxGrid. When i add a column using a subfield from a ADT Field, the column don't show the field value and the field is Ready Only. How to use correctly this field type in a cxgrid?

how to reproduce:

  1. Create a table in database like (i'm using Postgres):

    create table test (id integer, name text);

  2. In Delphi, Create a TFDQuery with a SQL text:

    select test from test

  3. Add the ADT field (test) in Field Editor. So, test.id and test.name will be created as individual fields too.

  4. Then add a TcxGrid in a form and create a Tableview adding the FDQuery's columns of step 3 (you can't do it automaticaly by "Retrieve Fields" Option on gridview editor).

  5. The issue: columns don't shows the field value, but the ADT column (test) like a record values

Ps: Using TDBGrid can show and edit the individual columns, but i need to use TcxGrid.


Solution

  • If you want show subfields of the ADT field as individual columns, the TFDQuery.ObjectView property must be set to false (Displaying_ADT). In this way, you can automatically or manually add the subfields present in the ADT field, and additionally, edit them individually in the TcxGrid.