How to get TProgressColumn to work when used with LiveBindings and datasets
My goal is to have a TGrid with multiple columns connected to TClientDataSet via LiveBindings. One of the columns is of type TProgressColumn.
The grid displays the data, but the progress bar column shows nothing (i.e. 0% progress).
TProgressColumn is connected to a field of type ftInteger. Values in this field range from 0 to 100.
I tried with ftSingle but no luck. I am setting the column type to TProgressColumn through the ColumnStyle property available in TLinkGridToDataSourceBindSourceDB / Columns.
The weird thing is that when I use TPrototypeBindSource to generate values - TProgressColumn works, but only for ftUInteger values. It doesn't work for ftInteger generators.
Here's a small demo (Delphi XE7):
When I put a breakpoint in TProgressCell.DrawCell () and step over the two conditions for Value.IsOrdinal and Value.IsType, it is skipped and the ClampValue gets the "Min" value, which is 0. There seems to be something wrong with the value. passed to the function.
Is there anything special about TProgressColumn? Do I need to use CustomFormat, CustomParse in TLinkGridToDataSourceColumn?
Is this a bug or am I missing something?
UPDATE: Thanks to "nompa" the mystery has been solved!
In fact "asInteger" is a well-known property of the TField ie class:
someDataSet.fieldByName('myFieldName').asInteger
In the CustomFormat property, you can access many things, including the self.asInteger properties. More information here:
source to share