Jump to content

how to add a TUniFileUploadButton in a menu


delagoutte

Recommended Posts

18 hours ago, delagoutte said:

is it possible to have an item menu that is a TUniFileUploadButton ?

1. UniHiddenPanel1 -> UniFileUploadButton1

2. 

procedure TMainForm.UniFormReady(Sender: TObject);
begin
  with UniFileUploadButton1 do
    JSInterface.JSAddListener('click', 'function(){'+ JSName +'.extractFileInput().click()}', YourUniMenuItem.JSMenuItem);

end;

 

Link to comment
Share on other sites

big thanks.

just a little problem, there seem to have a bug.

if you have the UniFileUploadButton1 in a UniHiddenPanel then the property "filter" of the UniFileUploadButton1 don't work.

if you don't use hiddenpanel and you set UniFileUploadButton1.visible = false it works.

Link to comment
Share on other sites

hum , there is a big problem with this method. the explorer file is opened but we don't enter in the method onCompleted.

on network, with the unifileuploadbutton we can see HandleEvent?Evt=upload&IsEvent=1&Obj=O253&fileno=0&filename=WEB-02-2015.WEXD&filetype=&filesize=23104&_S_ID=dbeajsdOzW105819AAB after i select the file.

but with the menu item there is no call to the server after the file is selected

 

Link to comment
Share on other sites

3 hours ago, delagoutte said:

if you have the UniFileUploadButton1 in a UniHiddenPanel then the property "filter" of the UniFileUploadButton1 don't work.

 

1 hour ago, delagoutte said:

but with the menu item there is no call to the server after the file is selected

 

OK, 

1. Don't use UniHiddenPanel...

2. UniFileUploadButton.Visible = False

3. 

procedure TMainForm.UniFormReady(Sender: TObject);
begin
  with
    UniFileUploadButton1 do
      JSInterface.JSAddListener('click', 'function(){'+ JSName +'.fileInputEl.dom.click()}', YourUniMenuItem.JSMenuItem);

end;

 

Link to comment
Share on other sites

  • 1 month later...
On 2/12/2020 at 8:02 AM, Sherzod said:

 

 

OK, 

1. Don't use UniHiddenPanel...

2. UniFileUploadButton.Visible = False

3. 


procedure TMainForm.UniFormReady(Sender: TObject);
begin
  with
    UniFileUploadButton1 do
      JSInterface.JSAddListener('click', 'function(){'+ JSName +'.fileInputEl.dom.click()}', YourUniMenuItem.JSMenuItem);

end;

 

hi Sherzod i have a similar question,  i want call that fileuploadbutton event from a cell click on unidbgrid (i tried a click from a action colum but, i have no sucess) i try like 

 

with UniFileUploadButton1 do
    JSInterface.JSAddListener('click', 'function(){'+ JSName +'.extractFileInput().click()}', UniDBGrid1.Columns[0].ActionColumn.Buttons.Items[0].JSMenuItem);

u know how i have success with this case ?

Link to comment
Share on other sites

38 minutes ago, crystian said:

hi Sherzod i have a similar question,  i want call that fileuploadbutton event from a cell click on unidbgrid (i tried a click from a action colum but, i have no sucess) i try like 

Hi Crystian,

Simply use OnColumnActionClick event:

procedure TMainForm.UniDBGrid1ColumnActionClick(Column: TUniDBGridColumn;
  ButtonId: Integer);
begin  
  case ButtonId of
    ...
    3 :
      begin
        UniFileUploadButton1.JSInterface.JSCall('extractFileInput().click', []);
      end;

  end;
end;

 

Link to comment
Share on other sites

5 hours ago, Sherzod said:

Hi Crystian,

Simply use OnColumnActionClick event:


procedure TMainForm.UniDBGrid1ColumnActionClick(Column: TUniDBGridColumn;
  ButtonId: Integer);
begin  
  case ButtonId of
    ...
    3 :
      begin
        UniFileUploadButton1.JSInterface.JSCall('extractFileInput().click', []);
      end;

  end;
end;

when i use this method, not activated event from onCompleted

how i can call for active a event OnCompleted after i selected my file

 

Link to comment
Share on other sites

Can you try this?

procedure TMainForm.UniDBGrid1ColumnActionClick(Column: TUniDBGridColumn;
  ButtonId: Integer);
begin  
  case ButtonId of
    ...
    3 :
      begin
        UniFileUploadButton1.JSInterface.JSCall('fileInputEl.dom.click', []);
      end;

  end;
end;

 

Link to comment
Share on other sites

39 minutes ago, Sherzod said:

Can you try this?


procedure TMainForm.UniDBGrid1ColumnActionClick(Column: TUniDBGridColumn;
  ButtonId: Integer);
begin  
  case ButtonId of
    ...
    3 :
      begin
        UniFileUploadButton1.JSInterface.JSCall('fileInputEl.dom.click', []);
      end;

  end;
end;

 

Worked Perfectly !! ty

Link to comment
Share on other sites

  • 2 years later...
On 3/25/2020 at 8:29 AM, Sherzod said:

Can you try this?

procedure TMainForm.UniDBGrid1ColumnActionClick(Column: TUniDBGridColumn;
  ButtonId: Integer);
begin  
  case ButtonId of
    ...
    3 :
      begin
        UniFileUploadButton1.JSInterface.JSCall('fileInputEl.dom.click', []);
      end;

  end;
end;

 

Is Perfectly .

Link to comment
Share on other sites

  • 1 year later...
  • 1 month later...

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...