Hybrid View

  1. #1
    Sencha User
    Join Date
    Feb 2013
    Location
    Sweden
    Posts
    13
    Vote Rating
    0
    Intraday is on a distinguished road

      0  

    Default Answered: Set value to text or number fields

    Answered: Set value to text or number fields


    Hello,

    -Controller
    MyController.js
    - View
    MyPanel

    I have created MyPanel.js in the view folder with some text and number fields and one button. In MyController.js I want to set different value to the fields in MyPanel every time someone push the button. Can you please tell me how I cant set values or disabe/enable the fields from the controller?

    Thanks in advance

  2. Try changing your selector to your alias

    Code:
    selector : 'myview'

  3. #2
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    8,927
    Answers
    656
    Vote Rating
    443
    scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future

      1  

    Default


    In your controller function, just get access to your for and then drill down:

    Code:
    refs : [
        {
             ref      : 'editForm',
             selector : 'myapp-user-edit'
        },
    ],
    // function
    Code:
    var me       = this,
        editForm = me.getEditForm(),
        field       = editForm.down('#field_user_name'); // itemId
    
    field.setValue('new value');

  4. #3
    Sencha User
    Join Date
    Feb 2013
    Location
    Sweden
    Posts
    13
    Vote Rating
    0
    Intraday is on a distinguished road

      0  

    Default


    Hello,
    Thank you for your reply. But it doesnt work when I try it.

    Quote Originally Posted by scottmartin View Post
    In your controller function, just get access to your for and then drill down:

    Code:
    refs : [
        {
             ref      : 'editForm',
             selector : 'myapp-user-edit'
        },
    ],
    // function
    Code:
    var me       = this,
        editForm = me.getEditForm(),
        field       = editForm.down('#field_user_name'); // itemId
    
    field.setValue('new value');

  5. #4
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    8,927
    Answers
    656
    Vote Rating
    443
    scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future

      0  

    Default


    Please provide more detail .. where does it break? perhaps if you show your code.

  6. #5
    Sencha User
    Join Date
    Feb 2013
    Location
    Sweden
    Posts
    13
    Vote Rating
    0
    Intraday is on a distinguished road

      0  

    Default


    In MyView.js which is in the view directory I have this field userName.
    Here is a bit of my code:
    Code:
    Ext.define('myapp.view.MyView, {
        extend: 'Ext.panel.Panel',
        alias: 'widget.myview,    width: 400,
        title: 'Input',
        initComponent: function() {
            var me = this;
            Ext.applyIf(me, {
                items: [
                    {
                        xtype: 'fieldcontainer',
                        height: 292,
                        width: 300,
                        layout: {
                            type: 'absolute'
                        },
                        fieldLabel: '',
                        hideLabel: true,
                        items: [
                            {
                                xtype: 'textfield',
                                x: 35,
                                y: 45,
                                fieldLabel: 'UserName',
                                name: 'userName'
                            },
    I took your code and pasted to the MyContoller.js which is in the controller directory
    Code:
    refs : [
        {
             ref      : 'editForm',
             selector : 'myapp.view.MyView'
        },
    ],
    And paste it in a function:

    Code:
    var me       = this,
        editForm = me.getEditForm(),
        field       = editForm.down('#userName'); // itemId
    field.setValue('Test');

    When I run it. It says that the something is undefind.

  7. #6
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    8,927
    Answers
    656
    Vote Rating
    443
    scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future

      1  

    Default


    Try changing your selector to your alias

    Code:
    selector : 'myview'

Thread Participants: 1

Tags for this Thread

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi