Search code examples
extjsextjs4extjs4.1

Ext.draw.Text dynamically change text


How to change text dynamically on Ext.draw.Text element?

this.textLabel = Ext.create "Ext.draw.Text"
        type  : 'text',
        text  : me.curValue,
        font  : '24px Arial',
        width : 100,
        height: 30,
        x : 100 
        y : 120

This method doesn't work:

   this.textLabel.setText("new text")

How can I do that?


Solution

  • I don't know if its a typo but your code should look something like this:

    this.textLabel = Ext.create('Ext.draw.Text', {
        type  : 'text',
        text  : me.curValue,
        font  : '24px Arial',
        width : 100,
        height: 30,
        x : 100, 
        y : 120
    });
    
    this.textLabel.setText("new text");
    

    Also what does this and me refer to? More code would be helpful. Anyways here is a working example: http://jsfiddle.net/6zczP/2/