2012-10-06 1 views
0

cxGrid에 'recordnumbers'를 추가하는 데 필요한 다음 코드가 있지만 그룹핑이있는 격자 인 경우 GroupRow가있을 때마다 한 번씩 번호가 매겨집니다. 번호가 누락되었습니다. 이레코드 번호를 추가 할 때 그룹 행 건너 뛰기

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; 

답변

1

, 같은 : 다음 그룹 인덱스가 -1 아니 그룹이없는 경우, 첫 번째 그룹은 인덱스를 가지고 있기 때문에

procedure TfrmProjectTasksActive.colCountGetDisplayText(Sender: TcxCustomGridTableItem; ARecord: TcxCustomGridRecord; var AText: string); 
var 
    Row, GrIdx: integer; 
begin 
    Row := Sender.GridView.DataController.GetRowIndexByRecordIndex(aRecord.RecordIndex, False); 
    GrIdx := Sender.GridView.DataController.Groups.DataGroupIndexByRowIndex[Row] + 1; 
    aText := Format('%.*d', [3, (Row + 1 - GrIdx)]); 
end; 

당신은 GrIdx+1 필요 0 등등.

+0

이것은 나를위한 속임수입니다. - 감사합니다. – OZ8HP

0

이 작동합니다 피하기 위해 모든 방법 (메모리 부족 작성, 테스트하지 ...) :

procedure TfrmProjectTasksActive.colCountGetDisplayText(Sender: TcxCustomGridTableItem; ARecord: TcxCustomGridRecord; var AText: string); 
var 
    Row: integer; 
    aRowInfo : TcxRowInfo; 
begin 
    aRowInfo := ARecord.GridView.DataController.GetRowInfo(ARecord.Index); 
    if not (aRowInfo.Level < ARecord.GridView.DataController.Groups.GroupingItemCount) then //test, if Row is not a group-row 
    begin 
    Row := Sender.GridView.DataController.GetRowIndexByRecordIndex(aRecord.RecordIndex, False); 
    aText := Format('%.*d', [3, (Row + 1)]); 
    end; 
end; 

희망 그렇지 않은 경우 미안, 제대로 내 마음에있다 상자에서 작업하십시오. 그러나 "aRowInfo"는 최소한 당신에게 올바른 힌트를 제공해야합니다 ... 또한 : "ARecord"의 "Index"와 "RecordIndex"의 차이에주의하십시오. 행이 다음 작업을해야하기 전에 그룹의 수를 빼면

+0

상자에서 제대로 작동하지 않습니다.하지만 다음 해결책은 그렇게 사용합니다. – OZ8HP