TWebTableControl render in cell

Hi,

I'm linking TWebButton with id="btn1" into TWebTableControl cell like this:

table.Cells[5,1]:='<button id="btn1"></button>';

but it doesn't work.
I think that it is general problem because e.g. TWebLinkLabel has the same problem.

Could you check this ?

Regards,

Correct way to do this:


type
  TForm1 = class(TWebForm)
    WebTableControl1: TWebTableControl;
    procedure WebFormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    wb: TWebButton;
    procedure BtnClick(Sender: TObject);
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.BtnClick(Sender: TObject);
begin
  ShowMessage('btn click');
end;

procedure TForm1.WebFormCreate(Sender: TObject);
begin
  webtableControl1.Cells[1,1] := 'abc';
  webtableControl1.Cells[1,2] := '<button id="btn">OK</button>';

  wb := TWebButton.Create('btn');
  wb.OnClick := BtnClick;
end;

Is it workaround or is this normal way for objects inside table cell?

The alternative is via event OnGetCellChildren

An example is explained here:
https://www.tmssoftware.com/site/blog.asp?post=473
Ok ... thanks ... but last question.

When I create button dynamically like your code

wb := TWebButton.Create('btn');

should I free button object like this
wb.Free;?

and what is the best place (event) when I should do this?

when you would remove the cell value in the TWebTableControl that would remove the HTML BUTTON element.

ok ... thx very much