[CLOSED] Set and Get Attribute and Value to a field

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1

    [CLOSED] Set and Get Attribute and Value to a field

    Hi

    I have a NumberField

     
    X.NumberField()
             .ID("txtDiscounta")
             .HideTrigger(true)
             .Name("m")
    I want to set an attribute to this,like

    foo=bar
    and after this I have a script ,where I select fields by name,and loop though with fields

    var fields = Ext.select('*[name=' m ']');
    fields.each(function (field) {
    
    })
    I need the Value for the particular Attribute.for each field.

    Is there property for assign attribute to a field?please give some sample.
    Last edited by Daniil; Sep 03, 2014 at 5:15 PM. Reason: [CLOSED]
  2. #2
    I try

       X.NumberField()
             .ID("txtDiscounta")
             .HideTrigger(true)
             .Name("m")
             .HideLabel(true)
            .EnableKeyEvents(true)
               .Listeners(l =>
             {
                 l.Render.Handler = @"this.getEl().set({
                             foo : 'bar'
                         });";
    
             })
    var fields = Ext.select('*[name=' m ']');
     fields.each(function (field) {
                console.log(field.getAttribute("foo"));
    
    })
    but not working
  3. #3
    Hi @matrixwebtech,

    I think your JavaScript code has a syntax error. If you run it, you should see an error message.
  4. #4
    Yes there are a javascript error,I rectify ,but not working,Its give null

    <script>
        Ext.onReady(function () {
            var fields = Ext.select('*[name= m]');
            fields.each(function (field) {
                console.log(field.getAttribute("foo"));
     
            })
        })
    
    </script>
    @(X.NumberField()
          .ID("txtDiscounta")
          .HideTrigger(true)
          .Name("m")
          .HideLabel(true)
         .EnableKeyEvents(true)
            .Listeners(l =>
          {
              l.Render.Handler = @"this.getEl().set({
                          foo : 'bar'
                      });";
     
          })
          )
  5. #5
    Ext.onReady fires before rendering of the NumberField.

    Another moment that this
    Ext.select('*[name= m]')
    retrieves an input HTML element, but a NumberField's getEl
    this.getEl()
    a table HTML element which is a wrapper from the input element.
  6. #6
    Hi, Danill

    but a NumberField's getEl

    this.getEl()
    a table HTML element which is a wrapper from the input element.
    not understand properly.its very help full for me if you provide some sample.

    Situation : I have 2 fields and I set 2 different value for the attribute ,when change event fires I take fields by name and check there attribute and doing a calculation as per attribute's value. so I write bellow code.can you please tell me ,how to achieve this.

    @using Ext.Net
    @using Ext.Net.MVC
    
    @{
        var X = Html.X();
        Layout = null;
    }
    <script>
        var calculate = function () {
            var fields = Ext.select('*[name= m]');
            fields.each(function (field) {
                console.log(field.getAttribute("calculationtype"));
    
            })
        }
    
    </script>
    @X.ResourceManager()
    
    
    @(X.NumberField()
          .ID("txt1")
          .HideTrigger(true)
          .Name("m")
          .HideLabel(true)
         .EnableKeyEvents(true)
            .Listeners(l =>
          {
              l.Render.Handler = @"this.getEl().set({
                          calculationtype : 'plus'
                      });";
              l.Change.Handler = "calculate()";
     
          })
          )
          @(X.NumberField()
          .ID("txt2")
          .HideTrigger(true)
          .Name("m")
          .HideLabel(true)
         .EnableKeyEvents(true)
            .Listeners(l =>
          {
              l.Render.Handler = @"this.getEl().set({
                          calculationtype : 'minus'
                      });";
              l.Change.Handler = "calculate()";
     
          })
          
          )

Similar Threads

  1. [CLOSED] EmailValidation attribute
    By jpadgett in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: Feb 14, 2013, 3:38 PM
  2. ClientConfig Attribute
    By PerfectElement in forum 1.x Help
    Replies: 6
    Last Post: Nov 11, 2011, 4:50 PM
  3. ServerMapping with more attribute
    By Maia in forum 1.x Help
    Replies: 3
    Last Post: Aug 12, 2010, 4:48 PM
  4. [CLOSED] [1.0] Form field name attribute
    By SandorD in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Feb 22, 2010, 7:39 AM
  5. [1.0] layouts attribute
    By [WP]joju in forum 1.x Help
    Replies: 2
    Last Post: Nov 12, 2009, 1:41 AM

Posting Permissions