红鱼儿

uniDBGrid标题上弹出右键菜单

uniDBGrid目前支持在单元格上弹出右键菜单,如果想在标题上弹出右键菜单,该怎么实现呢?

第一步:设置

UniMainModule.BrowserOptions.boDisableMouseRightClick = True

第二步:UniDBGrid1.ClientEvents.ExtEvents中写JS代码:

function headercontextmenu(ct, column, e, t, eOpts)
{
    ajaxRequest(this, "_hcmenu", ["x="+(e.clientX-this.getEl().getX()), 
                                  "y="+(e.clientY-this.getEl().getY())
    ]);
}

第三步:处理uniDBGrid.OnAjaxEvent:

procedure TMainForm.UniDBGrid1AjaxEvent(Sender: TComponent; EventName: string;
  Params: TUniStrings);
var
  X, Y: Integer;
begin
  if EventName = '_hcmenu' then
  begin
    X := Params.Values['x'].ToInteger();
    Y := Params.Values['y'].ToInteger();
    UniPopupMenu1.Popup(X, Y, Sender);
  end;

end;

 

posted on 2021-08-12 14:33  红鱼儿  阅读(399)  评论(0编辑  收藏  举报