unit cmpxxxxxx;
interface
uses
Variants, Classes, cxCustomData, cxGridTableView, SysUtils, ...;
type
// ...
TxxxDataSource = class(TcxCustomDataSource)
private
//... some private members here.
//... some private method or function here.
protected
function GetRecordCount: Integer; override;
function GetValue(ARecordHandle: TcxDataRecordHandle;
AItemHandle: TcxDataItemHandle): Variant; override;
procedure SetValue(ARecordHandle: TcxDataRecordHandle;
AItemHandle: TcxDataItemHandle; const AValue: Variant); override;
public
constructor Create(AAllObjects: TRes; ADataInfos: TDI);
function AppendRecord: TcxDataRecordHandle; override;
function InsertRecord(ARecordHandle: TcxDataRecordHandle): TcxDataRecordHandle; override;
procedure DeleteRecord(ARecordHandle: TcxDataRecordHandle); override;
procedure RefreshRecord(pTopIndex: Integer);
//... some properties here
end;
TxxxDataSource = class(TcxCustomDataSource)
private
//...
protected
function InsertRecord(ARecordHandle: TcxDataRecordHandle): TcxDataRecordHandle; override;
function AppendRecord: TcxDataRecordHandle; override;
procedure DeleteRecord(ARecordHandle: TcxDataRecordHandle); override;
function GetResourceValue(pResource: TUOResource; ARecordHandle: TcxDataRecordHandle;
AItemHandle: TcxDataItemHandle): Variant;
procedure SetResourceValue(pResource: TRes; ARecordHandle: TcxDataRecordHandle;
AItemHandle: TcxDataItemHandle; const AValue: Variant);
function GetRecordCount: Integer; override;
function GetValue(ARecordHandle: TcxDataRecordHandle;
AItemHandle: TcxDataItemHandle): Variant; override;
procedure SetValue(ARecordHandle: TcxDataRecordHandle;
AItemHandle: TcxDataItemHandle; const AValue: Variant); override;
public
constructor Create(ASelectResource: TRes; ADataInfos: TDI);
//...
end;
implementation
{ TxxxDataSource }
function TxxxDataSource.AppendRecord: TcxDataRecordHandle;
begin
//
end;
constructor TxxxDataSource.Create(AAllObjects: TRes;
ADataInfos: TDI);
begin
inherited Create;
FAllObjects := AAllObjects;
FDataInfos := ADataInfos;
end;
procedure TxxxDataSource.DeleteRecord(
ARecordHandle: TcxDataRecordHandle);
begin
inherited;
end;
function TxxxDataSource.InsertRecord(
ARecordHandle: TcxDataRecordHandle): TcxDataRecordHandle;
begin
//
end;
function TxxxDataSource.GetRecordCount: Integer;
begin
Result := FAllObjects.Count;
end;
function TxxxDataSource.GetValue(
ARecordHandle: TcxDataRecordHandle;
AItemHandle: TcxDataItemHandle): Variant;
var
lObj: TObj;
lColumnId: Integer;
Index: Integer;
lDataInfo: TDI;
lPos: Integer;
begin
if FAllObjects.Count <= 0 then exit;
if not (FAllObjects.Items[Integer(ARecordHandle)] is TObj) then
begin
Result := GetResourceValue(FAllObjects.Items[Integer(ARecordHandle)], ARecordHandle, AItemHandle);
Exit;
end;
lObj:= TObj(FAllObjects.Items[Integer(ARecordHandle)]);
lColumnId := GetDefaultItemID(Integer(AItemHandle));
case lColumnId of
0: Result := Integer(Pointer(lObj));
1: Result := lObj.IsSelect;
...
end;
end;
end.