zoukankan      html  css  js  c++  java
  • TcxCustomDataSource



    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.


  • 相关阅读:
    Element-UI饿了么时间组件控件按月份周日期,开始时间结束时间范围限制参数
    揭秘(爱奇艺、优酷、腾讯)在线视频网站视频2倍速、多倍速快速播放的前端实现方法
    提高敲代码的效率:程序员同扭曲时间的事儿抗争
    原生JS在网页上复制的所有文字后面自动加上一段版权声明
    .net core kafka 入门实例 一篇看懂
    聊聊Grpc使用中的坑以及怎么填
    MongoDB 上手开发实践(入门上手就这一篇)
    聊聊redis实际运用及骚操作
    .NET Core 微服务之Polly熔断策略
    .NET Core 微服务之Polly重试策略
  • 原文地址:https://www.cnblogs.com/tongy0/p/2121130.html
Copyright © 2011-2022 走看看