[CLOSED] Adding css class to FieldLabel property in TextField and to input as well.

  1. #1

    [CLOSED] Adding css class to FieldLabel property in TextField and to input as well.

    Hi,

    I making dynamically ext.net control type of TextField and i need get diffrent css class that default

    my code:
    TextField control = new TextField();
    control.ID = "someID";
    control.Listeners.AfterRender.Handler = " this.input.removeClass('x-form-text x-form-field').addClass('" + _viewValueCssClass + "');";// this not working properly
    control.Listeners.AfterRender.Handler = "this.label.removeClass('x-form-item-label').addClass('someCssClass');";//label
    am I doing something wrong?



    Regards
    Last edited by Daniil; Apr 25, 2012 at 12:12 PM. Reason: [CLOSED]
  2. #2
    Hi,

    The second Handler overrides the first one here:
    control.Listeners.AfterRender.Handler = "handler1";
    control.Listeners.AfterRender.Handler = "handler2";
    You should combine the two:
    control.Listeners.AfterRender.Handler = "handler1" + "handler2";
    Or use "+=":
    control.Listeners.AfterRender.Handler = "handler1";
    control.Listeners.AfterRender.Handler += "handler2";
  3. #3
    Quote Originally Posted by Daniil View Post
    Hi,

    The second Handler overrides the first one here:
    control.Listeners.AfterRender.Handler = "handler1";
    control.Listeners.AfterRender.Handler = "handler2";
    You should combine the two:
    control.Listeners.AfterRender.Handler = "handler1" + "handler2";
    Or use "+=":
    control.Listeners.AfterRender.Handler = "handler1";
    control.Listeners.AfterRender.Handler += "handler2";
    This:
    control.Listeners.AfterRender.Handler = "handler1";
    control.Listeners.AfterRender.Handler += "handler2";
    when i make += then no class is added to the label and input as well. And my entire Website crashed because of that change

    here is my code above:
                                    control.Listeners.AfterRender.Handler = " this.input.addClass('someClassForInput');";
                                    control.Listeners.AfterRender.Handler += "this.label.addClass('someClassForLabel');";
    When i did like before website works fine and
     
    control.Listeners.AfterRender.Handler = "this.label.addClass('someClassForLabel');";
    added class to label. but when changed label to input this handler don't added class to input

    any ideas?
  4. #4
    Well, there is no "input" property.

    To replace the default "x-form-field" class with your one, you can just set up the FieldClass property.
    http://docs.sencha.com/ext-js/3-4/#!...cfg-fieldClass

    To remove the "x-form-text" class, you should use:
    this.removeClass('x-form-text');
    Finally, the following should suite your needs.
    TextField tf = new TextField();
    tf.FieldClass = "your class to replace the default x-form-field";
    tf.Listeners.AfterRender.Handler = @"this.removeClass('x-form-text');
                                         this.label.addClass('your class for fieldLabel');";
  5. #5
    Quote Originally Posted by Daniil View Post
    Well, there is no "input" property.

    To replace the default "x-form-field" class with your one, you can just set up the FieldClass property.
    http://docs.sencha.com/ext-js/3-4/#!...cfg-fieldClass

    To remove the "x-form-text" class, you should use:
    this.removeClass('x-form-text');
    Finally, the following should suite your needs.
    TextField tf = new TextField();
    tf.FieldClass = "your class to replace the default x-form-field";
    tf.Listeners.AfterRender.Handler = @"this.removeClass('x-form-text');
                                         this.label.addClass('your class for fieldLabel');";
    Thats exacly what i asked for :)
    Thanks

Similar Threads

  1. [CLOSED] Use CSS Class for FieldLabel
    By sadaf in forum 1.x Legacy Premium Help
    Replies: 11
    Last Post: Sep 07, 2012, 6:05 PM
  2. Replies: 1
    Last Post: Apr 30, 2012, 7:34 AM
  3. Replies: 3
    Last Post: Dec 15, 2011, 12:18 PM
  4. [CLOSED] Input Mask for textfield
    By Hari_CSC in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Apr 20, 2010, 10:20 AM
  5. Replies: 10
    Last Post: Aug 31, 2008, 5:36 PM

Tags for this Thread

Posting Permissions