1. #1
    Sencha User
    Join Date
    Sep 2010
    Posts
    9
    Vote Rating
    0
    tonymayoral is on a distinguished road

      0  

    Default Answered: MVC form load values on button tap problem

    Answered: MVC form load values on button tap problem


    can't load values into formpanel with controller. formpanel does nothing Please help:
    Code:
    Ext.define('Prueba.controller.MyController', {
        extend: 'Ext.app.Controller',
    
    
        config: {
            refs: {
                formu: '#formulario'
            },
    
    
            control: {
    
                "#btpondata": {
                    tap: 'pondata'
                },
                "#btreset": {
                    tap: 'reset'
                }
            }
        },
    
    
      pondata: function(button, e, options) {
            var formu=this.getFormu();
            formu.setValues({
                fnombre: 'pepe',
                fapellido: 'martinez',
                fcedula: 'XS34343'
            });
    
    
            console.log(formu);
        },
    
    
    });


    console output:

    Ext.apply.create.Class
    • _activeItem: 0
    • _baseCls: "x-form"
    • _control: Ext.Object.classify.objectClass
    • _disabledCls: "x-item-disabled"
    • _hiddenCls: "x-item-hidden"
    • _itemId: "formulario"
    • _items: Ext.apply.create.Class
    • _styleHtmlCls: "x-html"
    • _useBodyElement: true
    • bodyElement: Ext.apply.create.Class
    • config: Ext.Object.classify.objectClass
    • element: Ext.apply.create.Class
    • eventDispatcher: Ext.apply.create.Class
    • getEventDispatcher: function () {
    • getId: function () {
    • getObservableId: function () {
    • getUniqueId: function () {
    • id: "formulario"
    • initConfig: function (){}
    • initialConfig: Object
    • initialized: true
    • innerElement: Ext.apply.create.Class
    • innerItems: Array[0]
    • items: Ext.apply.create.Class
    • managedListeners: Object
    • observableId: "#formulario"
    • onInitializedListeners: Array[0]
    • onItemAdd: function () {
    • parent: Ext.apply.create.Class
    • referenceList: Array[4]
    • renderElement: Ext.apply.create.Class
    • rendered: true
    • scrollableBehavior: Ext.apply.create.Class
    • tipElement: Ext.apply.create.Class
    • usedSelectors: Array[1]
    • __proto__: TemplateClass

  2. Your fields needs to be childs of the "forumulario" form panel like follows:

    Code:
    {
        xtype: 'formpanel',
        id: 'formulario',
        items: [
            {
                xtype: 'textfield',
                label: 'Nombre',
                name: 'fnombre'
            },
            {
                xtype: 'textfield',
                label: 'Apellido',
                name: 'fapellido'
            },
            {
                xtype: 'textfield',
                label: 'Cedula',
                name: 'fcedula'
            },
            {
                xtype: 'button',
                id: 'btcarga',
                text: 'Carga'
            },
            {
                xtype: 'button',
                id: 'btguarda',
                text: 'Guarda'
            },
            {
                xtype: 'button',
                id: 'btpondata',
                text: 'Pon Data'
            },
            {
                xtype: 'button',
                id: 'btreset',
                text: 'reset'
            }
        ]
    }

  3. #2
    Sencha - Services Team AndreaCammarata's Avatar
    Join Date
    Jun 2009
    Posts
    1,395
    Vote Rating
    23
    Answers
    148
    AndreaCammarata has a spectacular aura about AndreaCammarata has a spectacular aura about

      0  

    Default


    Did you set your form items name properties?
    I suggest you to take a look at this full guide on how to use Forms components.

    Hope this helps.
    Sencha Inc
    Andrea Cammarata, Solutions Engineer
    Owner at SIMACS

    @AndreaCammarata
    www.andreacammarata.com
    github: https://github.com/AndreaCammarata

    TUX components bundle for Sencha Touch 2.x.x
    https://github.com/AndreaCammarata/TUX


  4. #3
    Sencha User
    Join Date
    Sep 2010
    Posts
    9
    Vote Rating
    0
    tonymayoral is on a distinguished road

      0  

    Default


    Thanks for answering. Item names are set and still not working. I've read the guide but cant make it work following MVC way. When I try to call .reset() method from controller doesn't work either but when I try Ext.Msg.alert('test') on tap works ok.
    any ideas?

    Ext.define('Prueba.view.MyTabPanel', {
    extend: 'Ext.tab.Panel',


    config: {
    items: [
    {
    xtype: 'container',
    title: 'Inicio',
    items: [
    {
    xtype: 'button',
    id: 'bthola',
    text: 'Mi boton de buen rollo'
    }
    ]
    },
    {
    xtype: 'container',
    title: 'Formulario',
    items: [
    {
    xtype: 'formpanel',
    id: 'formulario'
    },
    {
    xtype: 'textfield',
    label: 'Nombre',
    name: 'fnombre'
    },
    {
    xtype: 'textfield',
    label: 'Apellido',
    name: 'fapellido'
    },
    {
    xtype: 'textfield',
    label: 'Cedula',
    name: 'fcedula'
    },
    {
    xtype: 'button',
    id: 'btcarga',
    text: 'Carga'
    },
    {
    xtype: 'button',
    id: 'btguarda',
    text: 'Guarda'
    },
    {
    xtype: 'button',
    id: 'btpondata',
    text: 'Pon Data'
    },
    {
    xtype: 'button',
    id: 'btreset',
    text: 'reset'
    }
    ]
    },
    {
    xtype: 'container',
    title: 'Otro'
    }
    ]
    }


    });

  5. #4
    Sencha - Services Team AndreaCammarata's Avatar
    Join Date
    Jun 2009
    Posts
    1,395
    Vote Rating
    23
    Answers
    148
    AndreaCammarata has a spectacular aura about AndreaCammarata has a spectacular aura about

      0  

    Default


    Your fields needs to be childs of the "forumulario" form panel like follows:

    Code:
    {
        xtype: 'formpanel',
        id: 'formulario',
        items: [
            {
                xtype: 'textfield',
                label: 'Nombre',
                name: 'fnombre'
            },
            {
                xtype: 'textfield',
                label: 'Apellido',
                name: 'fapellido'
            },
            {
                xtype: 'textfield',
                label: 'Cedula',
                name: 'fcedula'
            },
            {
                xtype: 'button',
                id: 'btcarga',
                text: 'Carga'
            },
            {
                xtype: 'button',
                id: 'btguarda',
                text: 'Guarda'
            },
            {
                xtype: 'button',
                id: 'btpondata',
                text: 'Pon Data'
            },
            {
                xtype: 'button',
                id: 'btreset',
                text: 'reset'
            }
        ]
    }
    Sencha Inc
    Andrea Cammarata, Solutions Engineer
    Owner at SIMACS

    @AndreaCammarata
    www.andreacammarata.com
    github: https://github.com/AndreaCammarata

    TUX components bundle for Sencha Touch 2.x.x
    https://github.com/AndreaCammarata/TUX


  6. #5
    Sencha User
    Join Date
    Sep 2010
    Posts
    9
    Vote Rating
    0
    tonymayoral is on a distinguished road

      0  

    Default


    thank you

  7. #6
    Sencha User riyaad's Avatar
    Join Date
    Jul 2011
    Location
    Cape Town
    Posts
    240
    Vote Rating
    1
    Answers
    6
    riyaad is on a distinguished road

      0  

    Default Great help ....

    Great help ....


    Thank you

Thread Participants: 2

Tags for this Thread