Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add simple dom-element into ExtJS container?

I want to add Canvas element into ExtJS Container element. But it accepts only Ext.Component, not any dom element.

Canvas create code:

canvas = document.createElement('canvas');

How to insert it into container, or I need to use another ext component? I need to have some resize logic for component, container have it.

like image 409
nkuhta Avatar asked Dec 03 '25 08:12

nkuhta


1 Answers

The best way to do this is to create a component where the element is the canvas. This way, you get all the built in layout stuff for "free" basically.

new Ext.container.Container({
    width: 400,
    height: 400,
    layout: 'fit',
    items: {
        xtype: 'component',
        autoEl: {
            tag: 'canvas'
        }
    }
});
like image 58
Evan Trimboli Avatar answered Dec 04 '25 20:12

Evan Trimboli



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!