I have the following code to add 'recordnumbers' in a cxGrid but it has the unwanted sideefeect that if it is a grid with grouping then it step one number every time there is a GroupRow and then there is a missing number. Any ways to avoid this
procedure TfrmProjectTasksActive.colCountGetDisplayText(Sender: TcxCustomGridTableItem; ARecord: TcxCustomGridRecord; var AText: string);
var
Row: integer;
begin
Row := Sender.GridView.DataController.GetRowIndexByRecordIndex(aRecord.RecordIndex, False);
aText := Format('%.*d', [3, (Row + 1)]);;
end;
Subtracting the number of groups before the row should work then, something like:
You need the
+1
in theGrIdx
because when there is no groups then group index is-1
, first group has a index0
and so on.