Jump to content

Custom uniDBGrid


Jaume

Recommended Posts

Hi, i'm trying to implement my own TuniDBGrid, adding the SelectedField to it:

 

The problem i have is that i can't find the default procedure AjaxEvent to override it:

TMyUniDBGrid = class(TUniDBGrid)
  private
    fSelectedField : TField;
    //procedure AjaxEvent(Sender: TComponent;EventName: string; Params: TStrings); override;
  public
    constructor Create(Aowner :TComponent); override;  
  published
  end;

 procedure Register;

implementation

procedure Register;
begin
  RegisterComponents('MYUNIGUI', [TSGIUniDBGrid]);
end;

constructor TMyUniDBGrid.Create(AOwner: TComponent);
begin
  inherited create(AOwner);
  //fSelectedField := Columns[GetCol].Field;
end;

function TMyUniDBGrid.SelectedField: TField;
begin
  Result := fSelectedField;
end;

{procedure AjaxEvent(Sender: TComponent;EventName: string; Params: TStrings); 
begin
   inherited;
   if SameText(EventName, 'select') then
    fSelectedField := Columns[StrToInt(Params.Values['colindex'])].Field;
end;}

So how can i implement it without having to use the OnAjaxEvent procedure?

 

Thank you very much.

Link to comment
Share on other sites

I think this should work:

function TMyUniDBGrid.SelectedField: TField;
begin
  if ((CurrCol >= 0)  and (CurrCol <= (Columns.Count-1)))  then
    Result := Columns[CurrCol].Field
  else
    Result:= nil;
end;
  • Upvote 1
Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...