How to specify Column Titles in a TTMSFMXLiveGrid.

I have a TTMSFMXLiveGrid linked to a ClientDataSet that have the TFields created at Runtime.

I need to specify which columns shall be show in the Grid, without delete any TField in the Dataset linked.

Did you know how to do this or where to find an example code?


There is no separate property to specify column headers / titles. The cells are accessed programmatically with TMSFMXGrid1.Cells[ACol, ARow], so the column headers can be set by passing the first row index (0)

I can't understand you. Sorry. 

At run time, can I use TMSFMXGrid1.Cells[ACol, ARow] to hide columns? 

To hide the columns you can use TMSFMXGrid.HideColumn(AColumnIndex). The previous reply was an answer to your first question by email.

Thank you Pieter. 

Can I asume that this context, Forums of your web page, are a good place to do this basic questions?

Other question related to your responses, this instructions shall be used in a procedure of initialization of the Grids or shall be used inside a event handler method of the Live Grid? 

The forum is a good place to do basic questions, the instructions can be set in the initialization routine of the grid. Or if you are connecting the grid via LiveBindings, you should hide the column after it has been created (if the dataset has finished updating).

I have the next problem with HideColumn:

I've defined the next constants:
      DELETE          =  0;
      CD_SERIES       =  1;
      NM_DLN_SLS      =  2;
      LN_DLN_SLS      =  3;
      DTE_DLN_SLS     =  4;
      DTE_HIS_DATE    =  5;
      CD_ITEM         =  6;
      DESCRIPTION     =  7;
      QTY_QUANTITY    =  8;

and I have the next procedure 

procedure TGetLinsDlnSlsController.InitializeGrid;
     FView.LiveGrid.Cells[DELETE         , 0] := '';
     FView.LiveGrid.Cells[CD_SERIES      , 0] := 'Serie';
     FView.LiveGrid.Cells[NM_DLN_SLS     , 0] := 'Número';
     FView.LiveGrid.Cells[LN_DLN_SLS     , 0] := 'Line';
     FView.LiveGrid.Cells[DTE_DLN_SLS    , 0] := 'Fecha';
     FView.LiveGrid.Cells[DTE_HIS_DATE   , 0] := 'Su Fecha';
     FView.LiveGrid.Cells[CD_ITEM        , 0] := 'Artículo';
     FView.LiveGrid.Cells[DESCRIPTION    , 0] := 'Descripción';
     FView.LiveGrid.Cells[QTY_QUANTITY   , 0] := 'Cantidad';

Whats the problem?

The Row 0 of the Grid, shows the titles and of course the text for "LINE" does not exists.

but in the rest of lines, exists the data for this column and of course all the data in the rest of columns apears  in a mis  column.

I can't understand why HideColumn only hide the column for Row zero.


I was overlooking you were using this in combination with an active LiveBindings connection. To hide a column you need to only import the columns you wish to see in the LinkGridToDataSource component columns editor. There you can add all fields you wish and then remove the fields you wish to hide. The HideColumn only works without an active LiveBindings connection.
What's the meaning of "active" LiveBinding connection? 
Can I deactivate a LiveBinding? How?
How do I import the columns across a LiveBinding Connection? I can't find the Import button or anything similiar. (try to delete some columns and after try to put newly on the collection)

The Columns Collection of the Grid don't have any effect over the presentation.

The columns don't have any property to know which Field in the Dataset represents. Cause of this, I cant elminate the correct. But if I count the position, I always eliminate the last, because no one have a relation with the fields.

I've changed the ID and Name property on some Columns. This don't have any effect over the viewed columns.

Is It anything wrong with the Grid? Or with the FMX version. 

Can't be as difficult to set Column properties based on a TDataSet connection.

Please!!! I need a solution or a help page!!!!

As mentioned in the previous post, please select the LinkGridToDataSource component which is created as soon as a LiveBindings connection is made. The component should be available as a subcomponent of the grid in the structure window. After selecting it, right-click and select "columns editor...". There you can choose which columns are added to the grid.

I'm sorry but I don't have not this property. I'm using TTMSFMXLiveGrid.  Cause TTMSFMXGrid is very very very slow.

There should be no difference. When creating visual LiveBindings this component should be created, otherwise you are not going to see data in the grid. It doesn't matter if the grid is TTMSFMXGrid or TTMSFMXLiveGrid

I see Data on the Grid. I asure you.

Did you add the bindings through the LiveBindings wizard or did you create the bindings programmatically?

LiveBinding Editor.
(when you are in the view, at button of the Object inspector appear a link to "LiveBinding") I use this standard method. 
If you are thinking in recommend me to use LinkBindings to create by code, my response is NOT. 

You can access to Columns Editor  clicking on the Object Inspector -> Property Columns.

Now, delete some columns.  And now add some columns. And say me..... 
The deleted columns represents to....  what fields on Dataset?
The added columns represents to... what fields on Dataset? 

There is a difference between the built-in columns and the columns that represent a field in the LiveBindings designer. The columns that you are referring to are the columns on the grid itself, which are only used to apply additional appearance / editing settings. By default all fields are added to the grid. If you wish to hide a specific column, this needs to be done on LiveBindings level, and not on grid level.

The steps taken to get a Link component is:

1) Drop a TTMSFMXLiveGrid on the form.
2) Right-click the component and select "Bind Visually"
3) Connect the grid to the dataset in the LiveBindings Designer
4) In the structure Window, a LinkGridToDataSource component should appear which has a columns editor.
5) Edit the columns and click on add all fields
6) Manually remove the fields you do not wish to see in the grid.

Whats the meaning of the TMSFMXLiveGrid.Columns Property?

I fund this columns property, but is at the same level that the Grid, not inside the grid.

The TTMSFMXLiveGrid columns property is used to specify font styles, sort formatting, text alignment, .... The columns are managed by the grid and have no relation to LiveBindings.Pieter Scheldeman2016-05-11 10:31:24