tolquito
tolquito

Reputation: 91

Ext JS renderTo a div

i cant show an Ext JS component in a basic div. How much i know it supposed to happen through renderTo. But when i try to give the id of the div in the Ext JS, it doesnt happen.

Here is the link https://jsfiddle.net/m10v973y/

<div id="bla"></div>

Ext.define('KitchenSink.view.form.FieldTypes', {
    extend: 'Ext.form.Panel',
    xtype: 'form-fieldtypes',
    renderTo:"bla",

    frame: true,
    title: 'Form Fields',
    width: 400,
    bodyPadding: 10,
    layout: 'form',

    items: [{
        xtype: 'textfield',
        name: 'textfield1',
        fieldLabel: 'Text field',
        value: 'Text field value'
    }, {
        xtype: 'hiddenfield',
        name: 'hidden1',
        value: 'Hidden field value'
    },{
        xtype: 'textfield',
        name: 'password1',
        inputType: 'password',
        fieldLabel: 'Password field'
    }, {
        xtype: 'filefield',
        name: 'file1',
        fieldLabel: 'File upload'
    }, {
        xtype: 'textareafield',
        name: 'textarea1',
        fieldLabel: 'TextArea',
        value: 'Textarea value'
    }, {
        xtype: 'displayfield',
        name: 'displayfield1',
        fieldLabel: 'Display field',
        value: 'Display field <span style="color:green;">value</span>'
    }, {
        xtype: 'numberfield',
        name: 'numberfield1',
        fieldLabel: 'Number field',
        value: 5,
        minValue: 0,
        maxValue: 50
    }, {
        xtype: 'checkboxfield',
        name: 'checkbox1',
        fieldLabel: 'Checkbox',
        boxLabel: 'box label'
    }, {
        xtype: 'radiofield',
        name: 'radio1',
        value: 'radiovalue1',
        fieldLabel: 'Radio buttons',
        boxLabel: 'radio 1'
    }, {
        xtype: 'radiofield',
        name: 'radio1',
        value: 'radiovalue2',
        fieldLabel: '',
        labelSeparator: '',
        hideEmptyLabel: false,
        boxLabel: 'radio 2'
    }, {
        xtype: 'datefield',
        name: 'date1',
        fieldLabel: 'Date Field'
    }, {
        xtype: 'timefield',
        name: 'time1',
        fieldLabel: 'Time Field',
        minValue: '1:30 AM',
        maxValue: '9:15 PM'
    }]
});

Upvotes: 0

Views: 5923

Answers (2)

BillyBarbarIan
BillyBarbarIan

Reputation: 123

What worked for me was wrapping my containers in an:

Ext.onReady(function() {"your container goes here" });

Ext.onReady() method will be called once the Ext JS is ready to render the Ext JS elements.

Check here for details.

I also had to remove width and height values from my container. I was not able to render to div with these declared.

Upvotes: 0

6ton
6ton

Reputation: 4214

You defined a class but never created an instance. So you need to add

Ext.create('form-fieldtypes', {
        renderTo: "bla"
    });

Also change:

xtype: 'form-fieldtypes',

to

alias: 'form-fieldtypes',

Updated your fiddle

Upvotes: 2

Related Questions