delphidevexpressvcldelphi-10.2-tokyotcxgrid

extending cxGrid with cxgridDbTableview


I have created a component by extending cxGrid and added some required properties, I want to do same and add some extra functionalities to cxGridDBTableView, I tried extending the cxGridDBTableView and added properties, but I am not able to access those properties because when i drop my TdxdmGrid It is using the default cxgridTableView but I want to use TdxdmGridDbtableView,

I tried like below, But it is showing 2 different components and the view I designed is not linked to the grid. enter image description here

How can this be achieved? Please help.

Thank you.


Solution

    1. You must register View with cxGridRegisteredViews, not with RegisterComponets()
    2. If you want TDXPDMGridDBTableView as default View you must override TcxGrid.GetDefaultViewClass(). DefaultView is View which is created when you put your Grid to Form
      TDXPDMGrid = class(TcxGrid)
        ...
        protected
          function GetDefaultViewClass: TcxCustomGridViewClass; override;
        ...
      end;
    ...
    function TDXPDMGrid.GetDefaultViewClass: TcxCustomGridViewClass;
    begin
      Result := TDXPDMGridDBTableView;
    end;
    ...
    initialization
      cxGridRegisteredViews.Register(TDXPDMGridDBTableView, 'PDM Table');
    ...
    finalization
      cxGridRegisteredViews.Unregister(TDXPDMGridDBTableView);