PDA

View Full Version : TextArea title: unable to update dynamically



samiset
6 Mar 2015, 4:42 AM
Here is the code:
var ta = {
xtype: 'textarea',
itemId: 'ta',
title: ' ', //will change dynamically
....
};

......
var recordId = '....'; // got it from record selection from the grid
var ta = Ext.ComponentQuery.query('.... > textarea[itemId=ta')[0];
ta.title = 'Selected Record Id: ' + recordId;

Firebug indicates that the title has been changed, but the display is not rendering the title.
Looks like I am missing some basic understanding of ExtJS.
From Google search, I found that may need to use ta.---.update(recordId) and no idea how to use this.

Could someone please help me here?

yeghikyan
6 Mar 2015, 4:53 AM
I am not sure, what do you mean by 'title' property, it is not found in docu, but I think, you mean fieldLabel. Somethinkg like this:

Ext.application({ name : 'Fiddle',


launch : function() {
var textArea = Ext.create('Ext.form.field.TextArea', {
title: "Title",
fieldLabel: "Name",
renderTo: Ext.getBody()
});
Ext.create('Ext.button.Button', {
text: "Rename",
renderTo: Ext.getBody(),
handler: function() {
textArea.setFieldLabel("Renamed Name");
}
})
}
});

yeghikyan
6 Mar 2015, 4:55 AM
So, instead of

var recordId = '....'; // got it from record selection from the grid
var ta = Ext.ComponentQuery.query('.... > textarea[itemId=ta')[0];
ta.title = 'Selected Record Id: ' + recordId;

use this:

var recordId = '....'; // got it from record selection from the grid
var ta = Ext.ComponentQuery.query('.... > textarea[itemId=ta')[0];
ta.setFieldLabel('Selected Record Id: ' + recordId);

samiset
6 Mar 2015, 5:29 AM
Thanks that (setFieldLabel) works great!
You are right, title does not exist as property in the documentation. But if I set title='...', it displays on top section of the textarea. But if add as a fieldLabel, it apprears to the left side of the textarea.
Actually, I am looking to display on top of the textarea. Can you display the same fieldLabel at the top instead of to the left side?

When you add textarea to the tabpanel, the title property looks very great and that's what I was struggling to make it working by changing its value dynamically.

Thanks

samiset
6 Mar 2015, 5:35 AM
I can use labelAlign='top'.

Thanks