View Full Version : Show/hide not working while using Ext.getCmp(<btn.id>)

9 Feb 2010, 5:09 AM
Hi there. i am having an issue trying to make a button show after hiding it. I am currently using the show/hide functions but once i have hidden the button i cannot make it show again.

below is the code that i am using:

here is where i hide the button

btn1.el.on('click', function(sender, e) {
// remove mapping
var tfValue = Ext.getCmp(this.id.replace('btn', 'fld')).getValue();
var newRec, aTfValue, newTfValue
// if there are more than 2 items in the textfiel only remove the last one
if (tfValue.indexOf(";") > 0) {
aTfValue = tfValue.split(";")
newRec = new Ext.data.Record({ name: aTfValue[aTfValue.length - 1] });
newTfValue = tfValue.substring(0, tfValue.lastIndexOf(";"));
} else {
newRec = new Ext.data.Record({ name: tfValue });
newTfValue = "";

_store_fContent.sort('name', 'ASC');
var txt = Ext.getCmp(this.id.replace("btn", "fld"));

and here is where i try to show it:

notifyDrop: function(ddSource, e, data) {
// Reference the record (single selection) for readability
var selectedRecord = ddSource.dragData.selections[0];
// Load the record into the form
//document.getElementById(sDropId).value = selectedRecord.data.name;
var txt = Ext.getCmp(sDropId.id);
var btn = Ext.getCmp(txt.id.replace("fld", "btn"))

if (txt.getValue().length > 0) {
txt.setValue(txt.getValue() + ";" + selectedRecord.data.name);
} else {

// Delete record from the grid. not really required.
return (true);

as you can see i am accessing the button component using Ext.getCmp, i have had a look in the forums and it seems that this problem occurs whhen using .get(...) but not getCmp(...)

plz help

P.S an additional not is that it seems that my click event does not fire

9 Feb 2010, 5:58 AM
Hey there. my bad, i have now fixed this problem. It turns out that the problem was the way i was adding my listsner to the button. Instead of using btn1.el.on... i found that the code should have been btn1.addListsner(...