Jump to content

Recommended Posts

Posted

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.

Posted

I will try with this code right now:

function TMyUniDBGrid.SelectedField: TField;
begin
  Result := Columns[CurrCol].Field;
end;

I'll let you know if it works.

Posted

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...