Sorting in TDBAdvGrid on calculated float field works not fine

I am using TDBAdvGrid Version with:
Pagemode = False
SortSettings.Show = True (rest default)
Sorting on all columns works fine except an amount column which is a calculated field.
Most rows are on the correct place, but some not.

Is there anything that I can do, or is this a known problem?


You have more information on the type of data that is used in the problematic column(s)?

The amount column is of type Double (see below, with and without the use of MemoryBuffer the sorting goes wrong).

procedure TfoOrderFacturatie.qOrderTeFactCalcFields(DataSet: TDataSet);
  lOrderId : Integer;
  lAmount  : Double;
  lAmount := 0;
  lOrderId := qOrderTeFactorderID.AsInteger;
  if not FMemoryBuffer.HasOrderAmout(lOrderId, lAmount) then
    qryPrijzenAfleverOrder.Parameters.ParamByName('HoofdOrdersId').Value := qOrderTeFactId.AsWideString;
    lAmount := GetOrderTotaalBedrag(qryPrijzen, qryStaffels) - GetOrderTotaalBedrag(qryPrijzenAfleverOrder, qryStaffels);
    FMemoryBuffer.AddToOrderAmout(lOrderId, lAmount);
  qOrderTeFactBedragMetStaffel.AsFloat := lAmount;

I could not reproduce this here so far.
Do you see any pattern on the rows not sorted correct?
Can this be due to mismatch between thousand/decimal separator used in the app versus the one returned/set by the DB field?

The decimal seperator is not set in the app, but is , (comma) Dutch in the Windows settings.
The users need to enter 1125,75 for 1.125,75.
Where can I find the settings of the DB field?
I used on the databasefield the DisplayFormat '#,##0.00'. That made the trouble to exist.
When I changed it to '0.00' the sorting worked fine again.
What need I to do, to get the sorting correct and to show the thousand separator again?

Can you try to implement for these columns the event grid.OnGetFormat with something like:

procedure TForm1.AdvStringGrid1GetFormat(Sender: TObject; ACol: Integer;
  var AStyle: TSortStyle; var aPrefix, aSuffix: string);
  if ACol in AMoneyColumn then
    AStyle := TSortStyle.ssFinancial

This topic was automatically closed 60 minutes after the last reply. New replies are no longer allowed.