Jump to content
uniGUI Discussion Forums
Sign in to follow this  
FabioMorcillo

UniEdit ClientEvents UniEvents call procedure in custom component

Recommended Posts

Hi,

I have trying UniGUI and create custom UniEdit with button.

In UniEdit UniEvents set beforeInit ->  lUniEdit.ClientEvents.UniEvents.Values['beforeInit'] :=
'function beforeInit(sender, config) {

   config.triggers = {

       search: {

           cls: ''fa fa-ellipsis-h'', handler: function() { *** need call public procedure on custom UniEdit here ***  } } } }';

 

Type

TCustomUniEdit = class(TUniEdit)

public

   procedure ButtonClick;

 

Is possible call ButtonClick in custom component using UniEvents ?

Thank you,

Share this post


Link to post
Share on other sites

Hi Sherzod,

 

I am using uniGUI Complete Trial Edition 1.50.0.1482.

 

We are developing a basic system with the resources we need for approval to buy UniGUI.

 

Thank you,

Share this post


Link to post
Share on other sites

Hi,

Thank you for your interest in UniGUI!

You can use ajaxRequest in handler fn:

function beforeInit(sender, config)
{
    config.triggers = { 
       search: {
           cls: 'fa fa-ellipsis-h', 
           handler: function() {  
               ajaxRequest(sender, '_search', ['val='+sender.getValue()]) 
           } 
       } 
    }
}

And OnAjaxEvent on the server side:

procedure TMainForm.UniEdit1AjaxEvent(Sender: TComponent; EventName: string;
  Params: TUniStrings);
begin
  if EventName = '_search' then
  begin
    ShowMessage(Params.Values['val']);
  end;

end;

 

Share this post


Link to post
Share on other sites

Thank you so much Sherzod

 

The ShowMessage in AjaxEvent open window message in server side. Can i open this showmessage in client side or open new Form in client side ?

 

Share this post


Link to post
Share on other sites
On 1/11/2019 at 6:38 PM, FabioMorcillo said:

The ShowMessage in AjaxEvent open window message in server side. Can i open this showmessage in client side or open new Form in client side ?

Hello,

Please clarify the question, 

What kind of form, what form of the message, 
and for what purpose do you want to use them?

Share this post


Link to post
Share on other sites

Hello :)

 

procedure TMainForm.UniEdit1AjaxEvent(Sender: TComponent; EventName: string;
  Params: TUniStrings);
begin
  if EventName = '_search' then
  begin
    ShowMessage(Params.Values['val']);
  end;

end;

When we click in search button and made this AjaxEvent, this ShowMessage don´t open dialog message in browser ( client-side )

 

We need when click in this search button, open new TUniForm in browser ( client-side )

 

Share this post


Link to post
Share on other sites
On 12/26/2018 at 3:36 PM, Sherzod said:

Hi,

Thank you for your interest in UniGUI!

You can use ajaxRequest in handler fn:


function beforeInit(sender, config)
{
    config.triggers = { 
       search: {
           cls: 'fa fa-ellipsis-h', 
           handler: function() {  
               ajaxRequest(sender, '_search', ['val='+sender.getValue()]) 
           } 
       } 
    }
}

And OnAjaxEvent on the server side:


procedure TMainForm.UniEdit1AjaxEvent(Sender: TComponent; EventName: string;
  Params: TUniStrings);
begin
  if EventName = '_search' then
  begin
    ShowMessage(Params.Values['val']);
  end;

end;

 

Hello, Sherzod ... okay?

Would it be possible to intercept the onChange event of a UniEdit through ajaxRequest?

Thank you!

Share this post


Link to post
Share on other sites
2 minutes ago, DEV_THS said:

Would it be possible to intercept the onChange event of a UniEdit through ajaxRequest?

Hello,

Sorry, can you please clarify your question?!

Share this post


Link to post
Share on other sites
8 minutes ago, Sherzod said:

Hello,

Sorry, can you please clarify your question?!

Yes of course!

I created a component that inherits from a UniDateTimePicker
and I have in this component a Subcomponent of the UniEdit Type

At some point I set values for this UniEdit and I'd like to intercept the OnChange event of it when that value is changed by the user ...

it would be possible?

Share this post


Link to post
Share on other sites
16 minutes ago, DEV_THS said:

Yes of course!

I created a component that inherits from a UniDateTimePicker
and I have in this component a Subcomponent of the UniEdit Type

At some point I set values for this UniEdit and I'd like to intercept the OnChange event of it when that value is changed by the user ...

it would be possible?

image.png.7ef52510a3b3caf0b4858486ba32a111.png

 

This FMaskEdit.OnChange does not fire when it has changes on the part of the user at run time.

Share this post


Link to post
Share on other sites
5 minutes ago, DEV_THS said:

image.png.7ef52510a3b3caf0b4858486ba32a111.png

 

This FMaskEdit.OnChange does not fire when it has changes on the part of the user at run time.

I got to have a similar case, where I managed to solve this way, it was a button that was also a subcomponent and when it was clicked the click event was not triggered.

procedure TPLUniEdit.LoadCompleted;
begin
  inherited;

  TUniForm(Self.OwnerForm).UniSession.AddJS('document.getElementById("'+
    self.Button.JSControl.Id +'").addEventListener("click", function() {ajaxRequest(' +
      Format('%s.%s', [self.OwnerForm.Name, self.Name]) + ', ''Search'',  { name: ''teste'', width: ''01''} );});');
end;

procedure TPLUniEdit.JSEventHandler(AEventName: string; AParams: TUniStrings);
begin
  inherited;
  if AEventName.Equals('Search') then
    OnClickBtn(nil);
end;

But in my other case, I could not solve in the same way with the OnChange of this UniEdit.

Share this post


Link to post
Share on other sites

 

4 hours ago, Sherzod said:

Hello,

Sorry, can you please clarify your question?!

Sherzod, I'm sorry, but did you come to understand my problem?

Share this post


Link to post
Share on other sites
51 minutes ago, DEV_THS said:

but did you come to understand my problem?

Sorry not yet... 

Share this post


Link to post
Share on other sites
35 minutes ago, Sherzod said:

Sorry not yet... 

okay ... let me try to explain it directly ... sometimes it gets a little easier, my problem is a little confusing indeed! lol

but the following is happening.

I have a component that inherits from a TuniDateTimePicker
and within this component I have a Subcomponent of type TUniEdit.

when I create my TuniDateTimePicker, I also create my TUniEdit I hedge an event on his OnChange.

everything works fine, but when I upload the application and make a change in my TUniEdit the OnChange event that I created in the create is not triggered.

and I need him to go through this event.

Could you more or less understand my problem now?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×