1. #1
    Sencha User
    Join Date
    Jan 2013
    Posts
    3
    Vote Rating
    0
    rishu1210 is on a distinguished road

      0  

    Default Unanswered: Use of Render/ Ext.getBody()

    Unanswered: Use of Render/ Ext.getBody()


    Hi All,

    Hope you are all doing good.

    I am new in ext-js 4. I have some queries during examples.

    app.js
    Code:
    Ext.application({
        name : 'MyApp',
        requires : ['Ext.window.MessageBox', 'MyApp.view.Student'],
    
    
        launch : function() {
            var student = Ext.create('MyApp.view.Student', {
              id : 'The Portal'
    
            });
             student.render(Ext.getBody())
            //console.log(student.getId());
        }
    });
    and Student.js

    Code:
    Ext.define('MyApp.view.Student', {
        extend : 'Ext.Component',
        config : {
            id : ''
        },
        constructor : function(config) {
            this.initConfig(config);
        }
    });
    In my above example, I want to display id of student on the page..How can i do that ?
    and don't know proper use of renderTo/ Ext.getBody() method,
    and during run this program i get following error :

    "Uncaught TypeError: Cannot read property 'beforerender' of undefined";

    Please guide me..

    Thanks

  2. #2
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    9,197
    Vote Rating
    482
    Answers
    690
    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


    You should not be setting the id to '', or with spaces. It is recommended that you do not set id at all and let the id gen automatically.

    I would suggest using itemId and then use componentQuery to get access:
    http://docs.sencha.com/ext-js/4-1/#!...ComponentQuery

    panel.down('#panel-itemid')

    As for the render .. if you are rendering to the body, then:

    renderTo: Ext.getBody(), or renderTo: document.body

    Typically would would render a viewport (auto render to body) or render a panel to the body and they draw the component in the panel.

    Scott.

Thread Participants: 1

Tags for this Thread