Page 1 of 4 123 ... LastLast
Results 1 to 10 of 35

Thread: How can i change the value of a text field in sencha touch?

  1. #1
    Sencha User arindam.hit's Avatar
    Join Date
    May 2012
    Location
    Hyderabad
    Posts
    99
    Answers
    1

    Default How can i change the value of a text field in sencha touch?

    I am scanning the barcode using barcode scanner plugins in phonegap. After getting the value, i want to show this in text field. Below is my text field code:

    Code:
    { xtype : 'textfield',     id : 'barcodtext',     width : 300,     margin : '0 0 0 10',     labelWidth : '40%',     label : 'Enter Barcode'
    }

    And in the controller, i am trying to set the barcode value in the text field.

    Code:
    window.plugins.barcodeScanner.scan(function(result) {
    Code:
     Ext.getCmp('barcodtext').setValue(result.text); }, function(error) {     alert("Scanning failed: " + error); 
    });


    When i am showing the value in dialog box, it is showing properly. But not able to set in textbox. How i can set the barcode?? Please help.

  2. #2
    Sencha User jay@moduscreate.com's Avatar
    Join Date
    Mar 2007
    Location
    DC Area =)
    Posts
    16,364
    Answers
    102

    Default

    looks like you're working with a PhoneGap plugin. Are you sure that result.text is the actual bar code text?

    How about breaking things down. yourTextField.setValue('test');


    Btw, STOP using Ext.getCmp!

  3. #3
    Sencha User arindam.hit's Avatar
    Join Date
    May 2012
    Location
    Hyderabad
    Posts
    99
    Answers
    1

    Default

    yes result.text is actual barcode. Bcause i am trying to show it in dialog, it is showing like below:

    Code:
     alert("We got a barcode\n" +
    //               "Result: " + result.text + "\n");
    And if i will not using getCmp, and if i am trying like
    Code:
    barcodtext.setValue(result.text);
    it is telling setValue() is not a method..

  4. #4
    Sencha User arindam.hit's Avatar
    Join Date
    May 2012
    Location
    Hyderabad
    Posts
    99
    Answers
    1

    Default

    The below error i am getting:

    Code:
    TypeError: Object #<an HTMLCollection> has no method 'setValue'

  5. #5
    Sencha Premium User bluehipy's Avatar
    Join Date
    Mar 2010
    Location
    Romania
    Posts
    628
    Answers
    67

    Default

    Try to reference the textfield in a controller and use that reference to set the value. Obviously you don;t obtain the right reference in there, though you should. Maybe you are using that id multiple times?

    Show me your view that has the barcode textfield item.

  6. #6
    Sencha User arindam.hit's Avatar
    Join Date
    May 2012
    Location
    Hyderabad
    Posts
    99
    Answers
    1

    Default

    This is my textbox code:

    Code:
     xtype : 'textfield',                                                    id : 'barcodetextfield',
                                                        width : 300,
                                                        margin : '0 0 0 10',
                                                        labelWidth : '40%',
                                                        label : 'Enter Barcode'
    Then in controller refs i am doing like below:

    Code:
     barcodebox : '#barcodetextfield',

    And then while getting the scan result, i am showing like below:

    Code:
    onScanButtonTap : function(button, e, options) {     window.plugins.barcodeScanner.scan(function(result) {
             this.getBarcodebox.setValue(""+result.text);
         }, function(error) {
             alert("Scanning failed: " + error);
         });
     }

  7. #7
    Sencha Premium User bluehipy's Avatar
    Join Date
    Mar 2010
    Location
    Romania
    Posts
    628
    Answers
    67

    Default

    In controller ref try:

    Code:
    barcodebox : 'textfield[id=barcodetextfield]'

  8. #8
    Sencha User arindam.hit's Avatar
    Join Date
    May 2012
    Location
    Hyderabad
    Posts
    99
    Answers
    1

    Default

    Tried. Got error:

    Code:
    Error in success callback: BarcodeScanner2 = TypeError: Cannot call method 'setValue' of undefined at :1751884546

  9. #9
    Sencha User arindam.hit's Avatar
    Join Date
    May 2012
    Location
    Hyderabad
    Posts
    99
    Answers
    1

    Default

    Can anyone help me please..

  10. #10
    Sencha Premium User bluehipy's Avatar
    Join Date
    Mar 2010
    Location
    Romania
    Posts
    628
    Answers
    67

    Default

    Copy/paste your view. I am sure you make some wrong moves in there

Page 1 of 4 123 ... LastLast

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •