I have a list/table in my html template. This is filled by a dataset. I do everything manually.
Until now:
I have a button in the list for each record. This button automatically gets a unique ID when it is generated. At the same time, I create a TWebButton that is linked to it.
It all works very well.
But in the future I would like to have a menu on the button. This menu gets about 6-9 menu items.
I was already uncomfortable with having to generate a button for each line. But now there will be almost 10 times as many.
Can I resolve the link using parameters? So that I only need one event and get the record ID and the menu item passed as parameters?
This is the code for html:
LRecId := String( RecordId);
DataColumn := '<td>' +
'<div class="dropdown">' +
'<button class="btn btn-outline-info btn-circle dropdown-toggle" type="button" id="btnListEntryMenu'+LRecId+'" ' +
'data-bs-toggle="dropdown" aria-expanded="false"> <i class="fa fa-bars"></i> </button>' +
'<ul class="dropdown-menu" aria-labelledby="btnListEntryMenu'+LRecId+'">' +
'<li><a class="dropdown-item" href="#">Install</a></li>' +
'<li><a class="dropdown-item" href="#">Register</a></li>' +
'<li><a class="dropdown-item" href="#">Item 3</a></li>' +
'<li><a class="dropdown-item" href="#">Item 4</a></li>' +
'<li><a class="dropdown-item" href="#">Something else here</a></li>' +
'</ul>' +
'</div>' +
'</td>' ;
And this is my binding currently:
procedure TframeServices.grOnBindControls(Sender: TObject; Element: TJSElement);
procedure AddButton( CurrentData: JSValue);
var
Button : TWebButton;
LRecId : String;
begin
LRecId := String( RecordId);
Button := TWebButton.Create( 'btnListEntryMenu'+LRecId);
Button.Parent := Self;
Button.Hint := LRecId;
Button.OnClick := MenuButtonClick;
end;
begin
MyDataset.First;
while not MyDataset.Eof do begin
AddButton( MyDataset.CurrentData);
MyDataset.Next;
end;
end;
Best regards
Thomas