I am having a hard time with Firemonkey. I think my brain is strong wired for VCL....
I read part of the documentation, and looked at the demos but some questions remain:
It seems that there is no much to be done visually, it is all by code: col width, col position, formating, etc. Is this right? or am I missing some place where can I change the properties of the column ?
I am using livebinding and I see that when I bind the BindSource all the columns are created, but my table have many column, I need few and in a different order that comes from the database. Does it need to be done by code?
I have 31 columns, and need to keep 10 on the grid, Do i need to count each one to find out the number?
How can I see all the columns? Horizontal Scroll does not work on design time.
I have looked to the livebinding demo and could see that on the binding component you can create only the columns needed. However it is complex, is there a simplier way? there is many values to be defined for each single column on that binding editor. Is that correct? In this case by code should be "easier".
On problem that I am having is that I use Aurelius and many properties from the datasource are pointers to objects, and all that get imported as columns. Then I need to create even more properties to display the values requeried, turning a single table in a buch of fields that needs to be hidden.
The LiveBindings implementation in the grid is not able to configure the number of columns that are displayed. This has to be configured in the link to the datasource. In the LiveBindings demo you can configure this in the LinkGridToDataSource1 component that is automatically generated when connecting the dataset to the grid. If you select the LinkGridToDataSource1 component in the structure pane and right-click it, you will be able to click "columns editor". the columns editor allows you to select which columns are displayed and in which order.
Grouping in combination with LiveBindings is not possible while LiveBindings is still active. You will need to deactivate the DataSet and set the flag to save the data:
TMSFMXGrid1.SaveDataSetData := True.
DataSet1.Active := False.
Afterwards you can override the OnGetCellData and return:
When setting SaveDataSetData, the data will be saved in inside the grid. Setting SaveDataSetData to true prevents the grid from being cleared after dataset changes to non-active.
It is currently not possible to group on more than one column.
When starting a group operation on a second column, the grid first performs an ungrouping operation.
Pieter, thank you a lot, I am almost getting the grid in the way needed. I lost a lot of days with the firemonkey grid with no success. I am trying to get the time back with TMS grid and hopefully present today a version of the software with it.
Question:
1) GridItens.Columns.Items[ACol].Name does not bring the name of the column. Is there a way to use the livebinding name to address the columns? I would prefer to stick with the name of the dataset field than a column number.
2) how can i get total in grouping? grouping is now working as expected! I have a column that is "Total" and I need that in the summary shows it calculated (SUM)
After I apply the grouping the widths that I set for the columns are wrong. It is like it shifted 1 column, because the first column is now the grouping column.
1) Only the column index is passed as a parameter, but you can access the columns in the LinkGridToDataSource1 component with the following code: LinkGridToDataSource1.Columns[ACol - 1].MemberName. Note that you have to substract 1 (or fixed columns) because ACol has included the FixedColumn property.
2) To bring up the sum of a specific column you can use the following code:
TMSFMXGrid1.GroupSum(Col);
About the column widths, we will have to investigate here what is going wrong, but to fix this, you can easily change the column widths after grouping with TMSFMXGrid1.ColumnWidths[Col] :=
The money value is interpreted in your data as a string, which is not valid for calculating the sum of all the values for each group. You will need to change the column type to a double so only the floating value is inserted in the grid. You can always apply money formatting afterwards.
As an alternative you could verify the contents of TMSFMXGrid1.Floats[ACol, ARow] and verify if this contains the values you would expect. The sum calculations of the grid rely on this property. Perhaps you could also take a look at the grouping demo which demonstrates how to apply a sum row for each group.
And Floats is most of the time with zero. Just in few cases has a value, and that is very strange.
Adding a breakpoint in the entity i can see that TMS Grid is looking for data AFTER this event. So it gets all the data at first moment as string, firing this event, and then goes all the records again, and in this case getting the values, but the values not going to Floats.
I took a look on all the demos already, specially the group demo, but some details are not explicit.