Page 3 of 4 FirstFirst 1234 LastLast
Results 21 to 30 of 35

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

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

    Default

    Add a ref to AddtoWishlog in the controller


    Code:
    wishlogPanel : 'addwishlog'



    and before you try to set the value of textfield, test existance:

    Code:
    if( this.getWishlogPanel() )
    {
      if ( this.getBoxTextfield() )
      {
          this.getBoxTextfield().setValue( 'xxx' );
      }else{
             alert( 'textfield does not exists' );
      }
    }else{
       alert( 'parent panel does not exists' );
    }

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

    Default

    Unfortunately it is showing this error:
    Code:
     Error in success callback: BarcodeScanner2 = TypeError: Object #<an Object> has no method 'getAddtoWishlog'

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

    Default

    copy paste controller

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

    Default

    One interesting observation..i change the code like below:

    Code:
    onScanButtonTap : function(button, e, options) {         window.foo = this; 
            window.plugins.barcodeScanner.scan(function(result) { 
            window.foo.getBarcodebox().setValue(result.text); 
            console.log(window.foo.getBarcodebox().getValue());
            }, function(error) { 
            alert("Scanning failed: " + error); 
            }); 
            }
    In console it is showing me the barcode which i scanned.
    But strangely it is not showing in the dialog..

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

    Default

    copy / paste controller

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

    Default

    Code:
    Ext.define('MyApp.controller.MyController', {    extend : 'Ext.app.Controller',
        config : {
            refs : {
                TitlePanel : 'login',
                dashboardpanel : 'dashboard',
                ConsumerSignup : 'consumersignup',
                AddtoWishlog : 'addwishlog',
                wishlogsummary : 'wishlogsummarylist',
                FeedbackSummary : 'feedbacksummarylist',
                ConsumerSignin : 'Consumersignin',
                barcodebox : '#barcodetextfield',
                labelid : 'title'
            },
            views : [ 'TitlePanel', 'dashboardpanel', 'ConsumerSignup',
                    'AddtoWishlog', 'wishlogsummary', 'FeedbackSummary',
                    'ConsumerSignin' ],
    
    
            control : {
                "#LoginBtn" : {
                    tap : 'onLoginButtonTap'
                },
    
    
                "#wishloghomebutton" : {
                    tap : 'onWishlogHomeButtonTap'
                },
    
    
                "#feedbacksummaryhomebutton" : {
                    tap : 'onFeedbackHomeButtonTap'
                },
    
    
                "#wishlogbtn" : {
                    tap : 'onWishlogButtonTap'
                },
    
    
                "#Feedbackbtn" : {
                    tap : 'onFeedbackButtonTap'
                },
    
    
                "#signup" : {
                    tap : 'onSignupButtonTap'
                },
    
    
                "#capturebtn" : {
                    tap : 'onCaptureButtonTap'
                },
    
    
                "#consumersignuphomebutton" : {
                    tap : 'onConsumerSignupHomeButtonTap'
                },
    
    
                "#selectphoto" : {
                    tap : 'onSelectPhotoButtonTap'
                },
    
    
                "#scanbutton" : {
                    tap : 'onScanButtonTap'
                }
    
    
            }
        },
    
    
        slideLeftTransition : {
            type : 'slide',
            direction : 'left'
        },
        slideRightTransition : {
            type : 'slide',
            direction : 'right'
        },
    
    
        onLoginButtonTap : function(button, e, options) {
    
    
            Ext.Viewport.setActiveItem(this.getDashboardpanel(),
                    this.slideLeftTransition);
            // this.getLabelid.setHtml('Dashboard');
        },
    
    
        onWishlogButtonTap : function(button, e, options) {
    
    
            Ext.Viewport.setActiveItem(this.getWishlogsummary(),
                    this.slideLeftTransition);
        },
    
    
        onFeedbackButtonTap : function(button, e, options) {
    
    
            Ext.Viewport.setActiveItem(this.getFeedbackSummary(),
                    this.slideLeftTransition);
        },
    
    
        onSignupButtonTap : function(button, e, options) {
    
    
            Ext.Viewport.setActiveItem(this.getConsumerSignup(),
                    this.slideLeftTransition);
        },
    
    
        onWishlogHomeButtonTap : function(button, e, options) {
    
    
            Ext.Viewport.setActiveItem(this.getDashboardpanel(),
                    this.slideRightTransition);
        },
    
    
        onFeedbackHomeButtonTap : function(button, e, options) {
    
    
            Ext.Viewport.setActiveItem(this.getDashboardpanel(),
                    this.slideRightTransition);
        },
    
    
        onConsumerSignupHomeButtonTap : function(button, e, options) {
    
    
            Ext.Viewport.setActiveItem(this.getDashboardpanel(),
                    this.slideRightTransition);
        },
    
    
        onCaptureButtonTap : function(button, e, options) {
            navigator.camera.getPicture(onPhotoURISuccess, onFail, {
                quality : 100,
                destinationType : Camera.DestinationType.FILE_URI
            });
    
    
            function onPhotoURISuccess(imageURI) {
                // console.log(imageURI);
                var largeImage = document.getElementById('capturedimage');
                largeImage.style.display = 'block';
                largeImage.src = imageURI;
            }
    
    
            function getPhoto(source) {
                // Retrieve image file location from specified source
                navigator.camera.getPicture(onPhotoURISuccess, onFail, {
                    quality : 100,
                    destinationType : destinationType.FILE_URI,
                    sourceType : source
                });
            }
            function onFail(message) {
                alert('It is failed: ' + message);
            }
    
    
        },
    
    
        onSelectPhotoButtonTap : function(button, e, options) {
            navigator.camera.getPicture(onPhotoURISuccess, onFail, {
                quality : 50,
                destinationType : navigator.camera.DestinationType.FILE_URI,
                sourceType : navigator.camera.PictureSourceType.PHOTOLIBRARY
            });
    
    
            function onPhotoURISuccess(imageURI) {
                // console.log(imageURI);
                var largeImage = document.getElementById('capturedimage');
                largeImage.style.display = 'block';
                largeImage.src = imageURI;
            }
    
    
            function getPhoto(source) {
                // Retrieve image file location from specified source
                navigator.camera.getPicture(onPhotoURISuccess, onFail, {
                    quality : 100,
                    destinationType : destinationType.FILE_URI,
                    sourceType : source
                });
            }
            function onFail(message) {
                alert('It is failed: ' + message);
            }
        },
        
        
        onScanButtonTap : function(button, e, options) { 
            window.foo = this; 
            window.plugins.barcodeScanner.scan(function(result) { 
            window.foo.getBarcodebox().setValue(result.text); 
            console.log(window.foo.getBarcodebox().getValue());
            }, function(error) { 
            alert("Scanning failed: " + error); 
            }); 
            }
    });
    here it is..

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

    Default

    Code:
     onScanButtonTap: function(button, e, options) {
            var me = this;
            window.plugins.barcodeScanner.scan(
    
    
            function(result) {
                var textfield = me.getBarcodebox();
                if (!textfield) {
                    alert('Bad textfield reference or not instantiated yet'); //try to get textfield by id           textfield = Ext.ComponentManager.get('barcodetextfield');            if(!textfield)          {             alert('There is no component with the id: barcodetextfield');             return;          }        }
                    if (textfield.setValue) {
                        textfield.setValue(result.text);
                    } else {
                        alert('Textfield object is not of expected type.');
                        console.log('textfield', textfield);
                    }
                    console.log(result.text);
                }
            }, function(error) {
                alert("Scanning failed: " + error);
            });
    
    
    
    
        }

    Try to use this instead. Please let me know what alerts do you get.

    *Please use the last update as I was having errors in the previous version of this post.

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

    Default

    Tried..no dialog is appeared..And even no error..

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

    Default

    I think, after this, my tabpanel is not refreshing..so it is not displaying the value..

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

    Default

    Are you sure you used this code?

    Code:
    onScanButtonTap: function(button, e, options) {
            var me = this;
            window.plugins.barcodeScanner.scan(
    
    
            function(result) {
                var textfield = me.getBarcodebox();
                if (!textfield) {
                    alert('Bad textfield reference or not instantiated yet'); //try to get textfield by id           textfield = Ext.ComponentManager.get('barcodetextfield');            if(!textfield)          {             alert('There is no component with the id: barcodetextfield');             return;          }        }
                    if (textfield.setValue) {
                        textfield.setValue(result.text);
                    } else {
                        alert('Textfield object is not of expected type.');
                        console.log('textfield', textfield);
                    }
                    console.log(result.text);
                }
            }, function(error) {
                alert("Scanning failed: " + error);
            });
    
    
    
    
        }

    It is imposible to get no alert and no error

Page 3 of 4 FirstFirst 1234 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
  •