Few Triggers in one TextField

  1. #1

    Few Triggers in one TextField

    Hi!

    I have a textfield and 2 triggers in it.
    How can I call client-method for one trigger and server-method for second trigger?

    ...
    .Triggers(
        new FieldTrigger() { 
            Icon = TriggerIcon.Clear, 
            Handler = "#{FilterComboBoxID}.setValue('');#{FilterComboBoxName}.setValue('');" 
        },
        new FieldTrigger() { Icon = TriggerIcon.Ellipsis }
     )
    .DirectEvents(de =>
        {
            de.TriggerClick.Url = Url.Action("GetGridPanelSearch", "MnemonicDiagram");
        })
  2. #2
    Hello, @Bogdan! And welcome to Ext.NET forums!

    There are several approaches you can follow to get it working the way you need.

    If you really want them as trigger fields, then you can just have the handler trigger a direct method instead of an event. The triggers are meant to be simpler.

    You can also use the RightButtons feature of the text field to include full-fledged button components to your text field where you can separately handle the client and server side events. See an example: Form > TextField > Buttons

    Hope this helps!
    Fabrício Murta
    Developer & Support Expert
  3. #3
    @fabricio.murta, thank you for your reply!

    I tried to use direct method in trigger`s handler, but I get an error "App.direct.GetTimeStamp is not a function".
    I checked functions inside App.direct and my function is really absent.
    For my controller class I added attribute [DirectController] and for my method I added attribute [DirectMethod]:
    [DirectMethod]
    public string GetTimeStamp()
    {
        return DateTime.Now.ToLongTimeString();
    }
    and in my view i wrote:
    ...
    .Triggers(
        new FieldTrigger() { Icon = TriggerIcon.Ellipsis, Handler = "App.direct.GetTimeStamp(
        {
            success: function (result) {
                Ext.Msg.alert('server time', result);
            }
        });" 
    })
    ...
    Can you help me, what is wrong?
  4. #4
    Hello, @Bogdan,

    Take a look on this example showing how direct methods can be used with MVC. I believe this has what you are missing in order to have your code working.

    - Events > Direct Method

    Hope this helps!
    Fabrício Murta
    Developer & Support Expert

Similar Threads

  1. [CLOSED] Change event triggers when textfield modified in code-behind
    By jstifel in forum 2.x Legacy Premium Help
    Replies: 3
    Last Post: Nov 27, 2013, 3:04 AM
  2. TriggerField and triggers
    By jurel in forum 1.x Help
    Replies: 1
    Last Post: Aug 31, 2010, 7:45 PM
  3. [CLOSED] SelectBox triggers
    By randy85253 in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Dec 25, 2009, 9:38 AM
  4. Custom triggers with combo
    By jurel in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Dec 30, 2008, 10:47 AM

Tags for this Thread

Posting Permissions