Jump to content

UniTabSheet header as a button


artem_niko

Recommended Posts

5 minutes ago, Sherzod said:

Hello, 

This post may help you:

 

This may also be useful to me in the future.
But, at the moment, I am interested in triggering an event when clicking on the tab title.
Or maybe it's possible to add just a regular button to the UniTabSheet header in general?

Link to comment
Share on other sites

18 minutes ago, artem_niko said:

Has no one done this before?

I have modified the above code (solution), try.

1. UniPageControl1.ClientEvents.ExtEvents ->

function boxready(sender, width, height, eOpts)
{
    var tab = sender;
    tab.getEl().on('click', function(e, target, options) {
        ajaxRequest(tab, '_click', ['tabIndx='+tab.tabPanel.tabBar.getRefItems().findIndex(item => item.id === target.getAttribute('data-componentid'))]);
    }, tab.getEl(), {
        preventDefault: true,
        delegate: '.x-tab'
    });
}

2. UniPageControl1.OnAjaxEvent ->

procedure TMainForm.UniPageControl1AjaxEvent(Sender: TComponent;
  EventName: string; Params: TUniStrings);
begin
  if EventName = '_click' then
  begin
    with (Sender as TUniPageControl) do
    begin
      CustomAttribs.Values['contextTab'] := Pages[Params.Values['tabIndx'].ToInteger()].Caption;
      ShowMessage(CustomAttribs.Values['contextTab'] + ' clicked...');
    end;
  end;
end;

 

  • Thanks 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...