WebDBTableControl and WebPopupMenu

I have a WebDBTableControl displaying data from an XDataWebDataSet. The WebDBTableControl is linked to an html template. I create a button in one of the columns using the OnGetCellChildren event and lick it a OnButtonClick event. All that works good.

Now I would like the button click to display a WebPopupMenu with 3 or 4 menu items because I have 3 or 4 actions that the user would like to preform. Is it possible to do that and have the popupmenu display below the button? I was able to get a popupmeu to display but it displays in the upper left of the browser window.

As an alternate option I can have the user click on the different cells in the row to preform the different actions. Is it possible to change the cursor to indicate that the cell is clickable?

Thanks for your help,

Elias

If the button is not absolute positioned, you can get the coordinate of the button via button.ElementHandle.getBoundingClientRect and use this result to position the popup menu at the bottom of this button.

Example code:

var
  r: TJSDOMRect;
begin
  r := webbutton1.ElementHandle.getBoundingClientRect;
  WebPopupMenu1.Popup(Round(r.left), Round(r.bottom));
end;

Bruno,

Thank you - exactly what I was hoping for.

Elias

Bruno,

The PopupMenu is displayed in the correct position if the list is short enough to fit into the browser window without scroll bars. If there are scroll bars, the PopupMenu is displayed in the wrong position. How do I get the correct position if there are scrollbars?

Thanks,
Elias

I figured this out which seems to work correctly. Is this the right solution?

Example code:
var
btnr: TJSDOMRect;
docr: TJSDOMRect;
begin
btnr := webbutton1.ElementHandle.getBoundingClientRect;
docr := document.body.getBoundingClientRect;
WebPopupMenu1.Popup(Round(btnr.left - docr.left), Round(btnr.bottom - docr.bottom));
end;

Thanks,
Elias

Yes, if you offset the scroll position this way.