[CLOSED] DisplayField change event does not fire

Page 1 of 2 12 LastLast
  1. #1

    [CLOSED] DisplayField change event does not fire

    Hi,
    I am trying to implement the listener when the DisplayField text changes. But it does not fire. Nor does the blur event. Can you please help?
    Last edited by Daniil; Dec 05, 2011 at 1:48 PM. Reason: [CLOSED]
  2. #2
    Hi,

    DisplayField has no Blur event and, respectively, no Change one.

    Please clarify how do you imagine a Blur event of DisplayField?
  3. #3
    Sorry. Stupid to try Blur event for a displayfield. Ignore blur.

    Change event is mentioned both in Sencha Docs and is listed in listeners section of displayfield in ext.net.

    I understand its because div does'nt hv a change event. However, Can you guide me what else can I do. I basically need to do something, when the text of display field changes.
  4. #4
    According documentation, change event is fired before a field blur
    There is no blur therefore change event is not fired (because blur event triggers change checking)
  5. #5
    Quote Originally Posted by amitpareek View Post
    Can you guide me what else can I do. I basically need to do something, when the text of display field changes.
    Please clarify how do you change the text?
  6. #6
    Thanks Vlad for that info.

    @Daniil :
    displayField1.setValue('someValue');
    Last edited by Daniil; Dec 05, 2011 at 1:36 PM. Reason: Please use [CODE] tags
  7. #7
    Well, I can suggest something like this:

    Example
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Ext.Net Example</title>
    
        <script type="text/javascript">
            var setValue = function (field, value) {
                var oldValue = field.getValue();
                field.setValue(value);
                if (oldValue !== value) {
                    field.fireEvent("change", field, value, oldValue);
                }
            }; 
        </script>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
            <ext:Button runat="server" Text="Change text:">
                <Listeners>
                    <Click Handler="setValue(DisplayField1, 'Hello World!');" />
                </Listeners>
            </ext:Button>
            <ext:DisplayField ID="DisplayField1" runat="server" Text="I'm first">
                <Listeners>
                    <Change Handler="Ext.Msg.alert('Change', this.id + '<br/>' + oldValue + '<br/>' + newValue);" />
                </Listeners>
            </ext:DisplayField>
            <ext:Button runat="server" Text="Change text:">
                <Listeners>
                    <Click Handler="setValue(DisplayField2, 'Hello World!');" />
                </Listeners>
            </ext:Button>
            <ext:DisplayField ID="DisplayField2" runat="server" Text="I'm second">
                <Listeners>
                    <Change Handler="Ext.Msg.alert('Change', this.id + '<br/>' + oldValue + '<br/>' + newValue);" />
                </Listeners>
            </ext:DisplayField>
        </form>
    </body>
    </html>
    You might be also interested in overriding the Ext.form.DisplayField to encapsulate this functionality into the class.
  8. #8
    Thanks Daniil!

    This is a good example. However, I have written the code to override the field according to my specs.

    Thanks for your help.
  9. #9
    Glad to help!
  10. #10
    Infact this is a very good example for future reference.
Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 1
    Last Post: Jun 28, 2012, 9:39 PM
  2. Replies: 7
    Last Post: Mar 22, 2012, 1:17 PM
  3. fire combobox's change event
    By jachnicky in forum 1.x Help
    Replies: 2
    Last Post: Dec 06, 2010, 4:33 PM
  4. Replies: 9
    Last Post: Nov 22, 2010, 4:06 AM
  5. [CLOSED] Change event on combobox doesn't fire
    By Stefanaccio in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Oct 06, 2010, 5:01 PM

Posting Permissions