Inserting controls as child of HTML elements



This is the code I have  to insert a button in the colum of webdbgrid

procedure TForm1.WebDBGrid1GetCellChildren(Sender: TObject; ACol, ARow: Integer;
  AField: TField; AValue: string; AElement: TJSHTMLElement);
var
  btn: TWebButton;
begin
  if ARow < 1 then
    exit;
    if ACol = 0 then
    begin
      btn := TWebButton.Create(self);
      btn.caption := 'Edit';
      AElement.innerHTML := '';
      btn.ParentElement := AElement;
      btn.onclick := btneditClick;
    end
  
based on the https://www.tmssoftware.com/site/blog.asp?post=473

on execution I am getting the following error. Can you please guide me 

Uncaught TypeError: this.FParentElement.appendChild is not a function
    at Object.SetParentElement (WEBLib.Controls.pas:3701)
    at Object.WebDBGrid1GetCellChildren (Unit6.pas:407)
    at Object.cb [as FOnGetCellChildren] (rtl.js:221)
    at Object.GetCellChildren (WEBLib.Grids.pas:1116)
    at Object.LoadRow (WEBLib.DBCtrls.pas:3638)
    at Object.LoadData (WEBLib.DBCtrls.pas:3580)
    at Object.ActiveChange (WEBLib.DBCtrls.pas:3227)
    at Object.cb [as FOnActiveChange] (rtl.js:217)
    at Object.ActiveChanged (WEBLib.DBCtrls.pas:2846)
    at Object.CheckActiveAndEditing (db.pas:7540)


Even AElement.style.setProperty('background-color','red'); is giving a similar error

What TMS WEB Core version do you use?

Is this 1.4 beta?
If so, the breaking change is explained in the release notes.

Thanks. But when the Event is created it still show AElement: TJSHTMLElement and not as AElement: TJSHTMLElementRecord


Manually added and changed AElement to AElement.element. It works fine. But when some changes are made to the code and you try to save it gives an error . Ignoring it works. 

The button gets added to the grid But when I click on the button the row does not get selected. How do I get to the row to pickup the details of the row ?

Did you properly and fully uninstall v1.3.8.0? Check in IDE menu : Help, About TMS WEB Core.


Yes 1.38 was still present thought the 1.4 says it is uninstalling the old one. Went to Windows apps manage and uninstall versions and reinstalled 1.4 and things are fine


The button gets added to the grid But when I click on the button the row does not get selected. Is there a way to get the row to be focused when the button in the row is clicked ?

Do you set the grid.Row property?

Yes I do get the row property . I added it to the button tag. But there is not gotorow function in dbgrid

Assuming it is the dataset active record you want to change, use Dataset.MoveBy()

Thanks

I did dataset.first and then dataset,moveby()

it works