Jump to content

UniEdit ClientEvents UniEvents call procedure in custom component


FabioMorcillo

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,

Link to comment
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;

 

Link to comment
Share on other sites

  • 3 weeks later...
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?

Link to comment
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 )

 

Link to comment
Share on other sites

  • 2 months later...
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!

Link to comment
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?

Link to comment
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.

Link to comment
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.

Link to comment
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?

Link to comment
Share on other sites

  • 11 months later...
On 4/2/2019 at 3:36 PM, DEV_THS said:

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?

You can't put an maskedit inside a datetimepicker.

Why do you need that? To put a mask?

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...