1
votes

i'm really new to extjs 4. im try to load default value form load as bellow

    launch: function() {
       Ext.create('panelid', {renderTo: 'form'});
      var form = this.up('panelid').getForm();
      var model = Ext.getCmp('modelid');
      form.loadRecord(model);
   }

that not work form me that gave to me undefined form

this my view class

Ext.define('panelid', {
    extend: 'Ext.form.Panel',

    alternateClassName: [
        'confpanel'
    ],
    requires: [
        'Ext.container.Container',
        'Ext.form.field.File',
        'Ext.button.Button'
    ],

    initComponent: function() {
        var me = this;

        Ext.applyIf(me, {
            items: [


                {
                    xtype: 'textfield',
                    itemId: 'NAME_2',
                    fieldLabel: 'SDFA',
                    name: 'NAME_2'
                },
                {
                    xtype: 'button',
                    handler: function(button, e) {
                        var form = this.up('form').getForm();
                        if(form.isValid()){
                            form.submit({
                                url: 'AA?submit=true'
                            });
                        }
                    },
                    itemId: 'btnSave',
                    text: 'Save'
                }
            ]
        });
        me.callParent(arguments);
    }

});

my store userClassName name is 'storeid' and my model userClassName is modelid this very simple question but it really hard to understand data communication in between server-client. please help to me this simple question

1
I would suggest you define your items inline with the rest of the class rather than trying to set it inside initComponent. You don't gain anything by it. As far as your error is concerned, I think you need to set an alias to your view. The command up('panelid') doesn't know what panelid is. Add the following: ..., alias: 'widget.panelid' after the extend.adaskos

1 Answers

0
votes

I see a couple of errors on your code:

renderTo should only be used with Elements and not components. E.g. Ext.getBody() or a div id on your html page For containers you should use applyTo.

And a model is not a Component. You cannot use getCmp to get the model reference.

You will have to define it the same way you defined the panel and then use the name you specified there as a reference.

Check the sencha documents on how to do all this. Its very well explained there.